On Aug 8, 2012, at 1:50 PM, Timothy Baldridge <[email protected]> wrote:
>
> >>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)))
Nice. I always enjoyed this variation on the whole make-point theme:
(defn make-point [x y]
(fn [f] (f x y)))
(defn point-x [pt]
(pt (fn [x y] x)))
(defn point-y [pt]
(pt (fn [x y] y)))
(def pt (make-point 1 2))
(println [(point-x pt)
(point-y pt)])
--
-- Jim Weirich
-- [email protected]
--
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