Re: let-while

2014-03-05 Thread Dan Cross
5, 2014 at 5:09 AM, Dan Cross wrote: > On Saturday, October 17, 2009 11:42:28 PM UTC-4, mbrodersen wrote: > >> It would be great to have while-let in contrib. Then I don't have to >> maintain let-while myself :-) > > > I'm reviving this ancient thread because of co

Re: let-while

2014-03-05 Thread Dan Cross
On Saturday, October 17, 2009 11:42:28 PM UTC-4, mbrodersen wrote: > It would be great to have while-let in contrib. Then I don't have to > maintain let-while myself :-) I'm reviving this ancient thread because of core.async. This seems like just the thing for the common pa

Re: let-while

2009-10-17 Thread mbrodersen
It would be great to have while-let in contrib. Then I don't have to maintain let-while myself :-) Morten --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send e

Re: let-while

2009-10-17 Thread John Harrop
On Sat, Oct 17, 2009 at 2:27 PM, Christophe Grand wrote: > (defmacro while-let > "Makes it easy to continue processing an expression as long as it is true" > [binding & forms] > `(loop [] > (when-let ~binding >~...@forms >(recur > This does look like the best implemen

Re: let-while

2009-10-17 Thread Timothy Pratley
On Oct 18, 5:27 am, Christophe Grand wrote: > (defmacro while-let >  "Makes it easy to continue processing an expression as long as it is true" >  [binding & forms] >   `(loop [] >      (when-let ~binding >       �...@forms >        (recur Nice! Would you be willing to add it to contrib? I

Re: let-while

2009-10-17 Thread mbrodersen
That's a nice improvement Christophe. Exactly the kind of answer I was looking for. Thanks! Morten --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googleg

Re: let-while

2009-10-17 Thread Christophe Grand
Hi all, On Sat, Oct 17, 2009 at 2:12 AM, John Harrop wrote: > On Fri, Oct 16, 2009 at 7:58 PM, mbrodersen wrote: > >> >> Hi, >> >> I am new to Clojure and I am wondering if there is anything similar to >> the following macro already built in: >> >&

Re: let-while

2009-10-17 Thread John Harrop
On Sat, Oct 17, 2009 at 3:32 AM, Timothy Pratley wrote: > > > But name is multiply evaluated. This might be preferable: > > Hi John, > > Could you explain this a bit more for me? I can understand if the > condition is duplicated that is unnecessary calculation but don't > appreciate the issue with

Re: let-while

2009-10-17 Thread mbrodersen
> I don't think the multiple evaluation matters in this case, since it's > the name parameter, which will in all sane cases be a simple symbol. > gensyms are needed when multiple evaluation could cause side-effects > or an expensive function to be computed multiple times, which is not > the case h

Re: let-while

2009-10-17 Thread Jarkko Oranen
On Oct 17, 10:32 am, Timothy Pratley wrote: > > But name is multiply evaluated. This might be preferable: > > Hi John, > > Could you explain this a bit more for me? I can understand if the > condition is duplicated that is unnecessary calculation but don't > appreciate the issue with the binding

Re: let-while

2009-10-17 Thread Timothy Pratley
> But name is multiply evaluated. This might be preferable: Hi John, Could you explain this a bit more for me? I can understand if the condition is duplicated that is unnecessary calculation but don't appreciate the issue with the binding name... both versions of the macro seem to expand to iden

Re: let-while

2009-10-17 Thread mbrodersen
I think I understand what you are trying to do John but it doesn't have the same semantics though. If you use the first definition, the following expression: (let-while [x (if (> (rand) 0.2) "Yep!" nil)] (println x) (println (str x will work correctly (it will print &

Re: let-while

2009-10-16 Thread John Harrop
On Fri, Oct 16, 2009 at 8:12 PM, John Harrop wrote: > (defmacro let-while > "Makes it easy to continue processing an expression as long as it > is true" > [[name expr] & forms] > (let [n# ~name] > `(loop [] >(let [~n# ~expr] >

Re: let-while

2009-10-16 Thread John Harrop
On Fri, Oct 16, 2009 at 7:58 PM, mbrodersen wrote: > > Hi, > > I am new to Clojure and I am wondering if there is anything similar to > the following macro already built in: > > (defmacro let-while >"Makes it easy to continue processing an expre

let-while

2009-10-16 Thread mbrodersen
Hi, I am new to Clojure and I am wondering if there is anything similar to the following macro already built in: (defmacro let-while "Makes it easy to continue processing an expression as long as it is true" [[name expr] & forms] `(loop []