Hi Aquahappy <[email protected]> writes:
[...] > 1: (define (compose f g) (lambda (x) (f (g x)))) > 2: (define (twice f) (compose f f)) > 3: (define fourth (twice sq)) > 4: (fourth 3) > > I've gotten this far and then I get stuck when I try to do line 2 from > the above: > > 1: (defn compose [f g] #(f (g %))) This is what I came up with. Note I also defined the sq function. user=> (defn compose [f g] #(f (g %))) #'user/compose user=> (defn twice [f] (compose f f)) #'user/twice user=> (defn sq [x] (* x x)) #'user/sq user=> (def fourth (twice sq)) #'user/fourth user=> (fourth 3) 81 Jim -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/clojure?hl=en
