Re: Is still idiomatic the ant simulation code?

2014-07-28 Thread Yu Shen
Hi Gary,

Your examination makes perfect sense in the context.

Thanks for your help!

Yu


On Tue, Jul 29, 2014 at 8:01 AM, Gary Johnson  wrote:

> Hi Yu,
>
>   This is a pretty dense (and IMHO non-idiomatic) piece of Clojure code.
> Without reading the paste you provided, I can at least tell you what
> appears to be happening here, given Clojure's evaluation semantics:
>
> 1. The [move ...] expression creates a vector of three functions.
> 2. The [(if ...)] expression creates a vector of three values (presumably
> numeric) resulting from calls to the ranks function.
> 3. The (wrand ...) form calls wrand on the ranks vector to presumably
> produce an integer index into the [move ...] vector.
> 4. The [move ...] vector is called on wrand's result, which should return
> one of the three functions it contains.
> 5. The function returned from step 4 is called on loc.
>
>   Happy hacking,
> ~Gary
>
>  --
> 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 a topic in the
> Google Groups "Clojure" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/clojure/sHLQN8m60qM/unsubscribe.
> To unsubscribe from this group and all its topics, 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: Is still idiomatic the ant simulation code?

2014-07-28 Thread Gary Johnson
Hi Yu,

  This is a pretty dense (and IMHO non-idiomatic) piece of Clojure code. 
Without reading the paste you provided, I can at least tell you what 
appears to be happening here, given Clojure's evaluation semantics:

1. The [move ...] expression creates a vector of three functions.
2. The [(if ...)] expression creates a vector of three values (presumably 
numeric) resulting from calls to the ranks function.
3. The (wrand ...) form calls wrand on the ranks vector to presumably 
produce an integer index into the [move ...] vector.
4. The [move ...] vector is called on wrand's result, which should return 
one of the three functions it contains.
5. The function returned from step 4 is called on loc.

  Happy hacking,
~Gary

-- 
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: Is still idiomatic the ant simulation code?

2014-07-28 Thread Yu Shen
What's the meaning of the following code:

 (([move #(turn % -1) #(turn % 1)]   (wrand [(if (:ant @ahead) 0 
(ranks ahead))   (ranks ahead-left) (ranks ahead-right)]))  
  loc)))


in https://www.refheap.com/paste/3099  from line 192 to 195?

Sorry to bother you, it's new to me, and it's really hard to Google, as the 
characteristic of the code is not well defined. I'm learning Clojure in 
ad-hoc manner, so I might not be aware some Clojure expression. Giving me 
some pointer to study further would be sufficient. 

By the context, it seems that it's trying to take a move.

Thanks a lot!

Yu

On Tuesday, June 12, 2012 7:19:22 PM UTC+8, Baishampayan Ghose wrote:
>
> >> While I agree that one could use a record in place of a struct, I 
> >> don't think structs are "obsolete", at least not officially. 
> >> 
> > 
> > From http://clojure.org/datatypes: 
> > 
> >>> Overall, records will be better than structmaps for all 
> >>> information-bearing purposes, and you should move such structmaps to 
> >>> defrecord. 
>
> In that case, defstruct, etc. should bear the same warning in 
> docstrings/metadata as well. 
>
> Regards, 
> BG 
>
> -- 
> Baishampayan Ghose 
> b.ghose at gmail.com 
>

-- 
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: Is still idiomatic the ant simulation code?

2012-06-12 Thread Baishampayan Ghose
>> While I agree that one could use a record in place of a struct, I
>> don't think structs are "obsolete", at least not officially.
>>
>
> From http://clojure.org/datatypes:
>
>>> Overall, records will be better than structmaps for all
>>> information-bearing purposes, and you should move such structmaps to
>>> defrecord.

In that case, defstruct, etc. should bear the same warning in
docstrings/metadata as well.

Regards,
BG

-- 
Baishampayan Ghose
b.ghose at gmail.com

-- 
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


Re: Is still idiomatic the ant simulation code?

2012-06-12 Thread Meikel Brandmeyer (kotarak)
Hi,

Am Dienstag, 12. Juni 2012 10:24:31 UTC+2 schrieb Baishampayan Ghose:
>
>
> While I agree that one could use a record in place of a struct, I 
> don't think structs are "obsolete", at least not officially. 
>
>
>From http://clojure.org/datatypes:

Overall, records will be better than structmaps for all information-bearing 
>> purposes, and you should move such structmaps to defrecord. 
>>
>
Kind regards
Meikel
 

-- 
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

Re: Is still idiomatic the ant simulation code?

2012-06-12 Thread Baishampayan Ghose
On Tue, Jun 12, 2012 at 1:37 PM, Yann Schwartz  wrote:
> That's great. I've also noticed the sample still uses defstruct which is
> made obsolete by defrecord.

While I agree that one could use a record in place of a struct, I
don't think structs are "obsolete", at least not officially.

Regards,
BG

-- 
Baishampayan Ghose
b.ghose at gmail.com

-- 
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


Re: Is still idiomatic the ant simulation code?

2012-06-12 Thread Yann Schwartz
That's great. I've also noticed the sample still uses defstruct which is
made obsolete by defrecord.

On Tue, Jun 12, 2012 at 7:59 AM, Baishampayan Ghose wrote:

> > Can you elaborate some suggestions?
>
> I have updated the Ants sim code to use the "idiomatic" JVM inter-op
> constructs and made some other minor changes.
>
> Will work fine on Clojure 1.4
>
> Here is the updated code - https://www.refheap.com/paste/3099
> This is the unified diff - https://www.refheap.com/paste/3100
>
> Needless to say, all mistakes are mine.
>
> Regards,
> BG
>
> --
> Baishampayan Ghose
> b.ghose at gmail.com
>
> --
> 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 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

Re: Is still idiomatic the ant simulation code?

2012-06-11 Thread Baishampayan Ghose
> Can you elaborate some suggestions?

I have updated the Ants sim code to use the "idiomatic" JVM inter-op
constructs and made some other minor changes.

Will work fine on Clojure 1.4

Here is the updated code - https://www.refheap.com/paste/3099
This is the unified diff - https://www.refheap.com/paste/3100

Needless to say, all mistakes are mine.

Regards,
BG

-- 
Baishampayan Ghose
b.ghose at gmail.com

-- 
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


Re: Is still idiomatic the ant simulation code?

2012-06-11 Thread Curtis Gagliardi
Here's the video: http://blip.tv/clojure/clojure-concurrency-819147
and you can get the code here (ants.clj):
http://www.lisptoronto.org/past-meetings/2009-05-clojure-ants-demo
or here if you don't want to download it: https://www.refheap.com/paste/3096

On Jun 10, 8:00 am, Alexey Kachayev  wrote:
> Guys, can you please share link where I can find the "ants demo" code?
>
> --
> Alexey Kachayev,
> CTO at KitApp, Inc.
>
>
>
>
>
>
>
> On Friday, June 8, 2012 at 4:44 PM, Stuart Sierra wrote:
> > The ants demo is definitely dated. It's not terrible, but the code could 
> > use some polishing/simplifying using newer additions to the language.
> > -S
>
> > --
> > 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 
> > (mailto: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 
> > (mailto: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 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


Re: Is still idiomatic the ant simulation code?

2012-06-11 Thread Alexey Kachayev
Guys, can you please share link where I can find the "ants demo" code?

-- 
Alexey Kachayev,
CTO at KitApp, Inc.


On Friday, June 8, 2012 at 4:44 PM, Stuart Sierra wrote:

> The ants demo is definitely dated. It's not terrible, but the code could use 
> some polishing/simplifying using newer additions to the language.
> -S
> 
> -- 
> 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 
> (mailto: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 
> (mailto: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 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

Re: Is still idiomatic the ant simulation code?

2012-06-09 Thread JuanManuel Gimeno Illa
Can you elaborate some suggestions?

Juan Manuel

On Friday, June 8, 2012 3:44:16 PM UTC+2, Stuart Sierra wrote:
>
> The ants demo is definitely dated. It's not terrible, but the code could 
> use some polishing/simplifying using newer additions to the language.
> -S
>
>

-- 
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

Re: Is still idiomatic the ant simulation code?

2012-06-08 Thread Stuart Sierra
The ants demo is definitely dated. It's not terrible, but the code could 
use some polishing/simplifying using newer additions to the language.
-S

-- 
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

Is still idiomatic the ant simulation code?

2012-05-29 Thread JuanManuel Gimeno Illa
I'm preparing an informal presentation about clojure concurrency and my 
plan is use the ant colony demo. Given the amount of changes in clojure 
since the time that code was written I wonder if the code is still 
idiomatic or parts of it should be adapted to modern clojure.

Any ideas would be much appreciated.

Thanks,

Juan Manuel

-- 
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