At this point you might be wondering how it’s possible to program with- out variables. How can you express something like X = X + 1 in Erlang? The answer is easy. Invent a new variable whose name hasn’t been used before (say X1), and write X1 = X + 1.
X=#todo{}.
X1 = #todo{status=urgent, text="Fix errata in book"}.
X2 = X1#todo{status=done}.
From Armstrongs thesis X = 5; X1 = X + 10;
I found those just by searching on "X1". There are more X1 examples in the erlang otp sources. Who knows what else is in there.It does, but you'll rarely see this pattern in any real Erlang code base. And when you see it, it will not be "littered". It's an exception, not an idiom.
And those samples from Joe's book and thesis are just snippets with no context. BTW, O'Reilly's "Erlang Programming" doesn't even provide such an example.
Edit: One example when I do use this pattern is constructing proplists for some function calls.
Or, rebinding variables is generally not the clearest way to express the intent of your calculation. Abstractions like fold are more pure descriptions of the desired calculation.
I do agree with the consensus that the clojure recur, expresses something about intent that is missing from Erlang.
I enjoy functional depictions of algorithms, but there are many programmers who are currently more comfortable with imperative code.