Re: scheme to clojure translation

2011-11-11 Thread Brian Goslinga
On Nov 8, 10:08 pm, Aquahappy wrote: > Hi Jim, > > Thanks so much! Using 'def' instead of 'defn' when defining a function > composed of functions was what I was missing. > > I can't believe I spent an hour trying to figure this out -- it seems > very obvious now. Doh! > > :) Notice that the Scheme

Re: scheme to clojure translation

2011-11-08 Thread Aquahappy
Hi Jim, Thanks so much! Using 'def' instead of 'defn' when defining a function composed of functions was what I was missing. I can't believe I spent an hour trying to figure this out -- it seems very obvious now. Doh! :) On Nov 8, 6:50 pm, Jim Crossley wrote: > Hi > > Aquahappy writes: > > [.

Re: scheme to clojure translation

2011-11-08 Thread Jim Crossley
Hi Aquahappy 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 %)))

Re: scheme to clojure translation

2011-11-08 Thread Ambrose Bonnaire-Sergeant
Hi Joshua, 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 %))) Try (defn compose [f g] (fn [x] (f (g x On Wed, Nov 9, 2011 at 9:10 AM, Aquahappy wrote: > Hi All, > > I'm working through Brian Harvey's 61a 2008 SICP lect

scheme to clojure translation

2011-11-08 Thread Aquahappy
Hi All, I'm working through Brian Harvey's 61a 2008 SICP lecture (http:// www.youtube.com/watch?v=ljOrUCqsixs) and could really use a hand translating a couple of simple lines from scheme to clojure. Here is the code: 1: (define (compose f g) (lambda (x) (f (g x 2: (define (twice f) (compo