Future

2018-05-19 Thread Renata Soares
Hello,

I am using future this way:

(doall (map #(future ()  (range 1 max-size))

When the max-size is small like around 6, if I don't print (println (doall 
(map #(future ()  (range 1 max-size))), the 
result  becomes empty

(Without print)

renata@renata:~/$ lein run
ranking  {}

(With print)
renata@renata:~/$$ lein run
(#object[clojure.core$future_call$reify__6962 0x6492fab5 {:status :ready, 
:val {:2 0, :4 0.0, :5 0, :1 2.5}}] 
#object[clojure.core$future_call$reify__6962 0x2c532cd8 {:status :ready, 
:val {:2 0}}] #object[clojure.core$future_call$reify__6962 0x294e5088 
{:status :ready, :val {:2 0, :4 0.0, :5 0, :1 2.5, :3 1.0}}] 
#object[clojure.core$future_call$reify__6962 0x51972dc7 {:status :ready, 
:val {:2 0, :4 0.0}}] #object[clojure.core$future_call$reify__6962 
0x3700ec9c {:status :ready, :val {:2 0, :4 0.0, :5 0}}])
ranking  {"1":2.5,"3":1.0,"5":0,"4":0.0,"2":0}

I am using (shutdown-agents) after the doall...

Any ideas why? I think it is because the futures aren't ready when 
(shutdown-agents) executes.

(When the max-size is big, run normally)

There is a way that I can wait for print the result until all futures are 
ready?

Thanks!

-- 
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/d/optout.


Re: Future

2018-05-19 Thread Alex Engelberg
Not sure what's going on with shutdown-agents, but you could call (run!
deref ...) to wait for all the futures to complete.

On Sat, May 19, 2018 at 3:29 PM Renata Soares 
wrote:

> Hello,
>
> I am using future this way:
>
> (doall (map #(future ()  (range 1 max-size))
>
> When the max-size is small like around 6, if I don't print (println (doall
> (map #(future ()  (range 1 max-size))), the
> result  becomes empty
>
> (Without print)
>
> renata@renata:~/$ lein run
> ranking  {}
>
> (With print)
> renata@renata:~/$$ lein run
> (#object[clojure.core$future_call$reify__6962 0x6492fab5 {:status :ready,
> :val {:2 0, :4 0.0, :5 0, :1 2.5}}]
> #object[clojure.core$future_call$reify__6962 0x2c532cd8 {:status :ready,
> :val {:2 0}}] #object[clojure.core$future_call$reify__6962 0x294e5088
> {:status :ready, :val {:2 0, :4 0.0, :5 0, :1 2.5, :3 1.0}}]
> #object[clojure.core$future_call$reify__6962 0x51972dc7 {:status :ready,
> :val {:2 0, :4 0.0}}] #object[clojure.core$future_call$reify__6962
> 0x3700ec9c {:status :ready, :val {:2 0, :4 0.0, :5 0}}])
> ranking  {"1":2.5,"3":1.0,"5":0,"4":0.0,"2":0}
>
> I am using (shutdown-agents) after the doall...
>
> Any ideas why? I think it is because the futures aren't ready when
> (shutdown-agents) executes.
>
> (When the max-size is big, run normally)
>
> There is a way that I can wait for print the result until all futures are
> ready?
>
> Thanks!
>
> --
> 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/d/optout.
>

-- 
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/d/optout.


Re: Future

2018-05-19 Thread Renata Soares
It worked, thanks!

Em sábado, 19 de maio de 2018 19:38:28 UTC-3, Alex Engelberg escreveu:
>
> Not sure what's going on with shutdown-agents, but you could call (run! 
> deref ...) to wait for all the futures to complete.
>
> On Sat, May 19, 2018 at 3:29 PM Renata Soares  > wrote:
>
>> Hello,
>>
>> I am using future this way:
>>
>> (doall (map #(future ()  (range 1 
>> max-size))
>>
>> When the max-size is small like around 6, if I don't print (println 
>> (doall (map #(future ()  (range 1 
>> max-size))), the result  becomes empty
>>
>> (Without print)
>>
>> renata@renata:~/$ lein run
>> ranking  {}
>>
>> (With print)
>> renata@renata:~/$$ lein run
>> (#object[clojure.core$future_call$reify__6962 0x6492fab5 {:status :ready, 
>> :val {:2 0, :4 0.0, :5 0, :1 2.5}}] 
>> #object[clojure.core$future_call$reify__6962 0x2c532cd8 {:status :ready, 
>> :val {:2 0}}] #object[clojure.core$future_call$reify__6962 0x294e5088 
>> {:status :ready, :val {:2 0, :4 0.0, :5 0, :1 2.5, :3 1.0}}] 
>> #object[clojure.core$future_call$reify__6962 0x51972dc7 {:status :ready, 
>> :val {:2 0, :4 0.0}}] #object[clojure.core$future_call$reify__6962 
>> 0x3700ec9c {:status :ready, :val {:2 0, :4 0.0, :5 0}}])
>> ranking  {"1":2.5,"3":1.0,"5":0,"4":0.0,"2":0}
>>
>> I am using (shutdown-agents) after the doall...
>>
>> Any ideas why? I think it is because the futures aren't ready when 
>> (shutdown-agents) executes.
>>
>> (When the max-size is big, run normally)
>>
>> There is a way that I can wait for print the result until all futures are 
>> ready?
>>
>> Thanks!
>>
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
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/d/optout.


Re: Future

2018-05-19 Thread Moe Aboulkheir
(doall (pmap  (range ...))) may be a viable approach also,
depending on the behaviour you want.

On Sat, May 19, 2018 at 11:42 PM, Renata Soares 
wrote:

> It worked, thanks!
>
> Em sábado, 19 de maio de 2018 19:38:28 UTC-3, Alex Engelberg escreveu:
>>
>> Not sure what's going on with shutdown-agents, but you could call (run!
>> deref ...) to wait for all the futures to complete.
>>
>> On Sat, May 19, 2018 at 3:29 PM Renata Soares 
>> wrote:
>>
>>> Hello,
>>>
>>> I am using future this way:
>>>
>>> (doall (map #(future ()  (range 1
>>> max-size))
>>>
>>> When the max-size is small like around 6, if I don't print (println
>>> (doall (map #(future ()  (range 1
>>> max-size))), the result  becomes empty
>>>
>>> (Without print)
>>>
>>> renata@renata:~/$ lein run
>>> ranking  {}
>>>
>>> (With print)
>>> renata@renata:~/$$ lein run
>>> (#object[clojure.core$future_call$reify__6962 0x6492fab5 {:status
>>> :ready, :val {:2 0, :4 0.0, :5 0, :1 2.5}}] 
>>> #object[clojure.core$future_call$reify__6962
>>> 0x2c532cd8 {:status :ready, :val {:2 0}}] 
>>> #object[clojure.core$future_call$reify__6962
>>> 0x294e5088 {:status :ready, :val {:2 0, :4 0.0, :5 0, :1 2.5, :3 1.0}}]
>>> #object[clojure.core$future_call$reify__6962 0x51972dc7 {:status
>>> :ready, :val {:2 0, :4 0.0}}] #object[clojure.core$future_call$reify__6962
>>> 0x3700ec9c {:status :ready, :val {:2 0, :4 0.0, :5 0}}])
>>> ranking  {"1":2.5,"3":1.0,"5":0,"4":0.0,"2":0}
>>>
>>> I am using (shutdown-agents) after the doall...
>>>
>>> Any ideas why? I think it is because the futures aren't ready when
>>> (shutdown-agents) executes.
>>>
>>> (When the max-size is big, run normally)
>>>
>>> There is a way that I can wait for print the result until all futures
>>> are ready?
>>>
>>> Thanks!
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
> 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/d/optout.
>

-- 
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/d/optout.