Re: A pipe macro for left-to-right coll streams

2009-02-14 Thread Perry Trolard
Hi Timothy, On Feb 12, 8:08 pm, Timothy Pratley timothyprat...@gmail.com wrote: What should happen when/if the seq arg doesn't contain the symbol? I believe how you currently handle it is correct and in the spirit of let- (alternatively it could be reported as an error) however it may raise

Re: A pipe macro for left-to-right coll streams

2009-02-12 Thread MattH
Plus a macro makes for shorter syntax, which is part of its purpose. Yeah the shorter syntax becomes even more apparent when you're piping/ threading through one-arg functions where it also saves on parenthesis, as the - and pipe macros expand to a list if necessary. E.g. this code in a comment

Re: A pipe macro for left-to-right coll streams

2009-02-12 Thread Timothy Pratley
Dare I suggest it - might be an interesting 'name' for 'pipe' given that - calls in prefix and 'pipe' calls in postfix. But I'd rather not see it contending with Datalog which - is nice to use. | isn't 'official', but it works fine... and aren't 'officially' usable in symbols either so why

Re: A pipe macro for left-to-right coll streams

2009-02-12 Thread Perry Trolard
On Feb 12, 12:15 pm, Meikel Brandmeyer m...@kotka.de wrote: I dislike this strategy for two related reasons: (1) It cannont be nested. Here is a pseudo-example: (?- 2 ... some computations ... (f (?- ... I don't have access to the outer ? anymore... ))) (2) Shadowing user bindings.

Re: A pipe macro for left-to-right coll streams

2009-02-12 Thread kyle smith
+1 as well for pipe and let- --~--~-~--~~~---~--~~ 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

Re: A pipe macro for left-to-right coll streams

2009-02-10 Thread David Powell
I like the pipe macro. I get a bit cognitively overloaded when map/filter/reduce are nested, I think it is made worse because they have 2 or more arguments, so you have to do a lot of jumping around to follow them. The left-to-right style is much easier to follow. I'm not sure about let-

Re: A pipe macro for left-to-right coll streams

2009-02-10 Thread MattH
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

Re: A pipe macro for left-to-right coll streams

2009-02-10 Thread Michael Reid
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

Re: A pipe macro for left-to-right coll streams

2009-02-10 Thread Meikel Brandmeyer
Hi, Am 10.02.2009 um 23:34 schrieb Michael Reid: Maybe _ is appropriate? = (let- _ (+ 1 2) (* 2 _) (+ _ 1)) 7 = (let- _ [1 2 3] (map inc _) (reduce + _) (+ _ 3)) 12 Or maybe ? ? I would not use _. _ is often used as don't care variable name. And this is certainly not what we want here.. ;)

Re: A pipe macro for left-to-right coll streams

2009-02-10 Thread Mark Fredrickson
Maybe _ is appropriate? = (let- _ (+ 1 2) (* 2 _) (+ _ 1)) 7 = (let- _ [1 2 3] (map inc _) (reduce + _) (+ _ 3)) 12 Or maybe ? ? Don't forget the wide variety of unicode symbols you have at your disposal: user= (let- ★ 2 (+ ★ 3) (- 10 ★ ) (map #(* ★ %) [2 3 4])) (10 15 20)

Re: A pipe macro for left-to-right coll streams

2009-02-09 Thread Mark Fredrickson
I like that implementation. The recursive call makes it much cleaner. A slight improvement (?) yet: (defmacro let- Provide a name that will be bound to the result of the first form. For each additional form, the variable will be used in the evaluation, and then rebound to the result

Re: A pipe macro for left-to-right coll streams

2009-02-09 Thread Jason Wolfe
I like that implementation. The recursive call makes it much cleaner. A slight improvement (?) yet: (defmacro let- Provide a name that will be bound to the result of the first form. For each additional form, the variable will be used in the evaluation, and then rebound to the result

A pipe macro for left-to-right coll streams

2009-02-08 Thread MattH
Hi, I want to suggest a pipe macro for dealing with collection streams, as a one-line variation on the built in - macro. Instead of writing a nested stream like this: ; Take the first 3 elements of the odd numbers in the range 1 to 20 (take 3 (filter odd? (range 1 20))) you can write this: