Tail/Non tail recursion

Bengt Kleberg Bengt.Kleberg@REDACTED
Thu Aug 28 14:23:10 CEST 2003


Jilani Khaldi wrote:
> Hi All,
> Is there a better way to write this code when there is a lot of elements 
> in the list?
> 
> square([H|T]) -> [(H*H|square(T)];
> square([]) -> [].
> 

square( Numbers ) ->
	Fun = fun( N ) ->
		N*N
	end,
	lists:map( Fun, Numbers ).


bengt




More information about the erlang-questions mailing list