[erlang-questions] [SPAM] Re: Cannot get the hang of single assignment

Tom Ayerst twa@REDACTED
Wed Aug 22 22:26:21 CEST 2007


Hi,

Thanks for the pointers.  I eventually worked this out.  The example 
code I came up with is here:

http://notwaving.net/wordpress/2007/08/20/a-basic-mutable-state-in-an-erlang-process/

Now, another question.  Is this a useful idiom in Erlang or is it the 
bastard offspring of an OO programmer trying to bring his baggage into 
the Functional/Actor world.

Cheers

tom

David Mercer wrote:
> On Friday, August 17, 2007, Tom Ayerst wrote:
>   
>> How should I track the state (position and vector) of each Boid?
>>     
>
> The short answer is that your boid is in a loop: implement that loop as a
> tail-recursive function, passing the state from the previous iteration in as
> arguments to the next.  Something like:
>
> 	boid_loop(State) ->
> 		. . .
> 		New_state = ...
> 		boid_loop(New_state).
>
> Does this help?
>
> Cheers,
>
> David
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
>   



More information about the erlang-questions mailing list