LoL lets you write: (with-cxrs (blah (foo (bar (cadddar x)))))
ie, it looks in your source, sees what you need defined, and makes a letfn. This looked fun, so I banged out an implementation: (defn cxr-impl [name] (when-let [op (second (re-matches #"c([ad]+)r" name))] `(comp ~@(map {\a `first \d `rest} op)))) (defmacro with-cxrs [& body] (let [symbols (remove coll? (tree-seq coll? seq body))] `(let [~@(for [sym symbols :let [impl (cxr-impl (name sym))] :when impl thing [sym impl]] thing)] ~@body))) user> (macroexpand-1 '(with-cxrs (inc (caadaaddadr x)))) (let [caadaaddadr (comp first first rest first first rest rest first rest)] (inc (caadaaddadr x))) On Nov 30, 11:27 pm, Tassilo Horn <tass...@member.fsf.org> wrote: > Peter Danenberg <pe...@factual.com> writes: > > Hi Peter, > > > Try as I might, I can't purge these anachronisms; so here are `car' to > > `cddddr' in all their glory: > > > http://clojars.org/cadr > > Nice. :-) > > > This implementation uses a Kleene-closure around the alphabet {a, d} > > to generate the names; and a macro to define them: > > > https://github.com/klutometis/cadr/blob/master/src/cadr/core.clj > > Is that inspired by the `cxr' macro (I think, that was its name) in Let > Over Lambda? One nice feature that seems missing from your version is a > macro for defining local functions on demand. I don't remember the > exact LoL syntax, but probably it would look something like that: > > (with-cxrs [foo caaaddddddaddr, > bar caddddddddaaaaaaaar] > (cons (foo myseq) (bar mysec))) > > Bye, > Tassilo -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en