On Thu, 25 Feb 2010 16:28:05 -0800 (PST) kuniklo <milese...@gmail.com> wrote:
> One of my least favorite things about common lisp was the degree of > nesting it required for sequential variable definitions. For common > code like this: > > (let (a vala) > (b valb) > ... do something with a & b... > (let (c (fn a b)) > (d (fn a b)) > ... do something with a, b, c, d... > (let (e (fn ...)) > (f (fn ....)) You might want to check out let*. > etc. You eventually get a very deeply nested function simply because > the values of variables assigned later in the code depend on values > determined earlier in the code. From what I can this is also the case > in clojure, correct? Nope. Clojure's let is like CL's let* > In contrast, the python/ruby/java approach (which I realize has its > own warts). > a = 1 > b = 2 > c = a * b > d = a + c > e = func(d) In clojure, you'd do: (let [a 1 b 2 c (* a b) d (+ a c) e (func d)] (calculation using a, b, c, d and e)) > I'm new to clojure so I'm wondering - are there idiomatic ways of > reducing the degree of scope-nesting let incurs or do people just tend > to try to avoid that kind of code with smaller sub functions etc? Anything particularly wrong with the example I gave you? <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