[erlang-questions] Function Declaration Syntax

Richard O'Keefe ok@REDACTED
Tue May 17 00:48:45 CEST 2011


On 16/05/2011, at 9:57 PM, Tony Finch wrote:

> Richard O'Keefe <ok@REDACTED> wrote:
>> 
>> An interesting alternative would be to allow
>> 
>>    fun F(N) when is_integer(N), N > 1 -> F(N-1) + F(N-2)
>>      ; F(1) -> 1
>>      ; F(0) -> 1
>>    end
>> 
>> and if the variable here were optional (either appearing in all
>> clauses or disappearing in all clauses) it would be clear that the
>> traditional form has a consistently repeated but invisible name.
> 
> A tangential observation ...
> http://bosker.wordpress.com/2011/04/29/the-worst-algorithm-in-the-world/

The example was intended to be RECOGNISABLE, not EFFICIENT.
I've been intimately familiar with the logarithmic method for the
last 30 years or more, and the closed-form solution (and how to
derive it and similar solutions to related problems) for at least
another 10 years before that.

I could have just said "think of the difference between LET and
named-LET in Scheme."




More information about the erlang-questions mailing list