On Tue, Feb 10, 2009 at 5:02 PM, MattH <mbhut...@gmail.com> wrote:
>
> The pipe macro is definitely not a new idea btw. It's taken from a
> thread posted on another lisp group.
>
> Someone posted a silly inflammatory attack on lisp, contrasting unix:
> "cat a b c | grep xyz | sort | uniq"
>  to how they'd imagine it in lisp:
> "(uniq (sort (grep xyz (cat a b c))))"
>
> A poster called Edward retorted:
> "
> (pipe (cat a b c) (grep xyz) (sort) (uniq))
> 'Nuff said.
> "
>
> Here's the link, but *not* recommend reading :)
>    
> http://groups.google.com/group/comp.lang.lisp/browse_thread/thread/d0ce288e1cd22654/cc25683874ecc457
>
> When watching the Abelson and Sussman (SICP) lectures online, when
> Abelson was using map/filter/reduce etc, he would sometimes explain
> the code from the inside out, pointing to the most inner part, then
> working outwards and up.
>
> I get the same cognitive overload on seeing lots of nesting. Expanding
> out onto multiple lines helps, but you still hit a wall.
>
> (transform-g
>  (transform-f
>  ...
>          (transform-b)
>              (transform-a)
>                  (some-generator))))))))
>
>  vs
>
> (pipe
>  (some-generator)
>  (transform-a)
>  (transform-b)
>  ...
>  (transform-f)
>  (transform-g)
> )
>
> The nested form would tell me "it's time to generalise and write a new
> function". But if using the pipe form I'd happily expand and edit the
> chain of transforms. It's pretty easy to swap parts of the chain, or
> disable transforms by commenting them out.
>
> The let-> form is really interesting and a nice implementation -
> pretty amazing to see solution to the general case so quickly. I have
> the same reservation about using it though, I wouldn't want "x" to
> mean something different in the same lexical scope. Maybe it's just a
> case of finding a good name for "x"? Something like "the-evaluation-of-
> the-previous-form", but shorter..

Maybe _ is appropriate?

=> (let-> _ (+ 1 2) (* 2 _) (+ _ 1))
7
=> (let-> _ [1 2 3] (map inc _) (reduce + _) (+ _ 3))
12

Or maybe ? ?

/mike.

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