Erlang article #1 on

Richard A. O'Keefe <>
Fri Aug 18 01:46:16 CEST 2006

"Ryan Rawson" <> wrote:
	You'd have to break Erlang to insert loops.


	First off you'd have variables that need to be changed.


	If you want to loop, you probably want to map or fold.


	If you need to loop you might want to use gen_server instead,

Not for processing a data structure you wouldn't/

	or at the last resort use a tail recursive call.
Why would that be the LAST resort?

Friends, we had a thread about looping not so very long ago.
By the end of it, there was a concrete proposal for a construct looking

    (let p1 = i1 then s1, ..., pk = ik then sk
     for generators-and-filters
     in final-result
As a trivial example, let's compute the mean of the positive elements
of a list:

    (let N = 0 then N+1, S = 0 then S+X
     for X <- List, X > 0
     in S/N

It's pretty much what you get if you hybridise Scheme DO loops with
list comprehension, and it's as pure as anyone could wish for.

Of course there is room for disagreement about whether it is useful
enough to add to the language, but let there be no nonsense about
it "breaking" Erlang.

More information about the erlang-questions mailing list