>>I'm looking for medium-scale examples of using function-generating
functions.


I'm not sure if this is exactly what you're looking for, but this sort of
thing is pretty cool:

(defn make-point [x y]
  (fn [member]
    (cond (= member :x) x
             (= member :y) y)))

We're basically creating an immutable object without using a single data
structure:

(def pnt (make-point 1 2))

=> (pnt :x)
1
=> (pnt :y)
2

You can even get a bit more fancy:

(defn make-point [x y]
  (fn [member]
    (cond (= member :x) x
          (= member :y) y
          (= member :with-x)
            (fn [newx]
               (make-point newx y)))))

Timothy


>

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