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

David Mercer dmercer@REDACTED
Fri Aug 17 21:44:36 CEST 2007


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




More information about the erlang-questions mailing list