Re: Function returns nil

2013-06-21 Thread Phillip Lord
"Jim - FooBar();" writes: > On 21/06/13 14:01, Neale Swinnerton wrote: >> >> >> I really wish there were support for this in clojure.core: both >> "dofor" >> and "domap" would be very useful. >> >> >> mapv is non-lazy, which gives you the semantics of a domap as long as you >> don't m

Re: Function returns nil

2013-06-21 Thread Jay C
Cheers Jim, my problem is now solved using :when and then doing (apply str (fn)) to the return value. On Friday, 21 June 2013 14:08:19 UTC+1, Jim foo.bar wrote: > > 'for' accepts a :when clause which will get you even further :) > > Jim > > ps: it also accepts a :let clause if you find it usefu

Re: Function returns nil

2013-06-21 Thread Jay C
On Friday, 21 June 2013 11:17:44 UTC+1, Jay C wrote: > > Hi, I'm fairly new to Clojure and need help with a problem. The following > function always returns nil, whereas it should return the value of "line" > (which is not nil - I've tested). > > (defn find-line-in-output [regex] >> (wi

Re: Function returns nil

2013-06-21 Thread Jim - FooBar();
'for' accepts a :when clause which will get you even further :) Jim ps: it also accepts a :let clause if you find it useful On 21/06/13 14:06, Jay C wrote: Thanks for all the input. Using for as in Phillip's suggestion seems to have gotten me somewhere, but now the function returns during eve

Re: Function returns nil

2013-06-21 Thread Jay C
Thanks for all the input. Using for as in Phillip's suggestion seems to have gotten me somewhere, but now the function returns during every iteration. What am I missing to have it only return when a conditional statement is satisfied? -- -- You received this message because you are subscribed

Re: Function returns nil

2013-06-21 Thread Jim - FooBar();
On 21/06/13 14:01, Neale Swinnerton wrote: I really wish there were support for this in clojure.core: both "dofor" and "domap" would be very useful. mapv is non-lazy, which gives you the semantics of a domap as long as you don't mind a vector over a sequence exactly! also, that

Re: Function returns nil

2013-06-21 Thread Neale Swinnerton
I really wish there were support for this in clojure.core: both "dofor" > and "domap" would be very useful. > mapv is non-lazy, which gives you the semantics of a domap as long as you don't mind a vector over a sequence -- -- You received this message because you are subscribed to the Google Gr

Re: Function returns nil

2013-06-21 Thread Jim - FooBar();
aaa yes, of course! :) Jim On 21/06/13 13:47, John D. Hume wrote: If you use for, which is lazy, wrap it in a doall to force it to do its work before with-open closes your reader. On Jun 21, 2013 6:52 AM, "Jim" > wrote: Only use 'doseq' when you don't ca

Re: Function returns nil

2013-06-21 Thread Phillip Lord
I don't think that will work. for is lazy, so by the time it evals, the code will have dropped out of the scope of with-open. So: (defn read-stuff-2 [] (with-open [r (java.io.BufferedReader. (java.io.FileReader. "myfile.txt"))] (for [line (line-seq r)] line))) fail

Re: Function returns nil

2013-06-21 Thread John D. Hume
If you use for, which is lazy, wrap it in a doall to force it to do its work before with-open closes your reader. On Jun 21, 2013 6:52 AM, "Jim" wrote: > Only use 'doseq' when you don't care about the reuturn value. In other > words only for side-effect-y code. Use 'for' instead... > > Jim > >

Re: Function returns nil

2013-06-21 Thread Alan Forrester
On 21 June 2013 11:17, Jay C wrote: > Hi, I'm fairly new to Clojure and need help with a problem. The following > function always returns nil, whereas it should return the value of "line" > (which is not nil - I've tested). > >> (defn find-line-in-output [regex] >> (with-open [rdr (reader

Re: Function returns nil

2013-06-21 Thread Jim
Only use 'doseq' when you don't care about the reuturn value. In other words only for side-effect-y code. Use 'for' instead... Jim On 21/06/13 11:17, Jay C wrote: Hi, I'm fairly new to Clojure and need help with a problem. The following function always returns nil, whereas it should return

Function returns nil

2013-06-21 Thread Jay C
Hi, I'm fairly new to Clojure and need help with a problem. The following function always returns nil, whereas it should return the value of "line" (which is not nil - I've tested). (defn find-line-in-output [regex] > (with-open [rdr (reader belarc-output-filepath)] > (do