You've probably seen these, but if not, Doug Crockford's video series
on javascript walks through a number of interesting information
sharing examples like the ones you're looking for using
fn-generating-fns-

http://yuiblog.com/crockford/

They're all great but "act 3 - function the ultimate" is especially juicy.

The motivation for his examples is a little different than it would be
for clojure, because that pattern is basically javascript's only
abstraction trick. And certainly the semantics are different too.

But if for whatever reason you haven't seen these videos, they're
terrific and will probably spur some ideas.


On Wed, Aug 8, 2012 at 12:48 PM, Brian Marick <mar...@exampler.com> wrote:
> I'm looking for medium-scale examples of using function-generating functions. 
> I'm doing it because examples like this:
>
> (def make-incrementer
>      (fn [increment]
>        (fn [x] (+ increment x))))
>
> ... or this:
>
> (def incish (partial map + [100 200 300]))
>
> ... show the mechanics, but I'm looking for examples that would resonate more 
> with an object-oriented programmer. Such examples might be ones that close 
> over a number of values (which looks more like an object), or generate 
> multiple functions that all close over a shared value (which looks more like 
> an object), or use closures to avoid the need to have some particular 
> argument passed from function to function (which looks like the `this` in an 
> instance method).
>
> Note: please put the flamethrower down. I'm not saying that "looking like 
> objects" is the point of higher-order functions.
>
> I'll give full credit.
>
> -----
> Brian Marick, Artisanal Labrador
> Contract programming in Ruby and Clojure
> Occasional consulting on Agile
>
>
> --
> 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

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