On Thu, 1 Jul 2010 12:50:00 -0700 (PDT)
Tim Robinson <tim.blacks...@gmail.com> wrote:

> and now  corrected!
> 
> (defmacro anaphoric-recur [parm-binds expr & parms]
>       "An anaphoric recursive function that takes a vector of blind
>        bindable vars, an expression that can handle the bindable vars.
>        and the parameters. 'self' is used to call the function
> recursively."
>   `(letfn [(~'self ~parm-binds
>              (do ~expr))]
>                (~'self ~...@parms)))
> 
> > (anaphoric-recur [x] (if (= x 0) 1 (* 2 (self (dec x)))) 5)
> 32

Cool. I'd worry about using ~' to capture variables in a macro, except
rich hickey said that's intentional in
http://markmail.org/message/d6cubdwwxgjq4po6.

        <mike
-- 
Mike Meyer <m...@mired.org>             http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

-- 
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

Reply via email to