Reducers might be a good fit if you want to parallelize a concat.

http://clojure.com/blog/2012/05/08/reducers-a-library-and-model-for-collection-processing.html


On Mon, Feb 10, 2014 at 4:28 PM, Gary Trakhman <gary.trakh...@gmail.com>wrote:

> (apply concat (session))?
>
> or consider mapcat..
>
> if the thing behind session needs to be concurrent, it needs to be
> concurrent at that point, not in the code that calls it.  There's no way to
> generally make it concurrent from above unless you know more about what's
> happening below.
>
>
> On Mon, Feb 10, 2014 at 4:15 PM, Haim Ashkenazi 
> <haim.ashken...@gmail.com>wrote:
>
>> Hi JIm,
>>
>> The reason I don't use repeatedly is because (unless I'm mistaken) I
>> would get a list of 5 outputs of session (file lists of between one and
>> 5 elements each). I am interesting in taking the elements returned from
>> session and concat it to what was already generated.
>>
>> Regarding concurrency, As I said, I don't really need it for this but I
>> just thought that if the generation processed had to do some hard
>> computation I would like to be able to use all CPU's.
>>
>> Thanks
>>
>> /haim
>>
>>
>> On Mon, Feb 10, 2014 at 9:35 PM, Jim - FooBar(); <jimpil1...@gmail.com>wrote:
>>
>>>  If `session` returns a list, why don't you just do `(take 5
>>> (repeatedly session))` ???
>>> with regards to concurrency I am not sure what you're asking...you want
>>> to do the same thing from multiple threads and accumulate a global result?
>>>
>>> Jim
>>>
>>>
>>>
>>> On 10/02/14 18:46, Haim Ashkenazi wrote:
>>>
>>> Hi
>>>
>>>  I have a simple code that generates a list of maps:
>>>
>>>  (defn test-data
>>>   [nsamples]
>>>    (loop [acc []]
>>>     (if (>= (count acc) nsamples)
>>>       acc
>>>       (recur (concat acc (session))))))
>>>
>>>  The session function returns a list of one to five generated maps. The
>>> idea is to get a list of (not much more then) nsamples generated maps.
>>> This code runs fairly fast for my needs but out of curiosity I was
>>> wondering how would I make it run concurrently?
>>>
>>>  Thanks in advance
>>> --
>>> Haim
>>>  --
>>> 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 unsubscribe from this group and stop receiving emails from it, send
>>> an email to clojure+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>>  --
>>> 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 unsubscribe from this group and stop receiving emails from it, send
>>> an email to clojure+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>
>>
>>
>> --
>> Haim
>>
>> --
>> 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 unsubscribe from this group and stop receiving emails from it, send an
>> email to clojure+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to