Try/Cond

Roberto Amorim wolfoxbr@REDACTED
Fri Oct 24 15:54:57 CEST 2003


> > Personally, I prefer the (working) version:
>                            ^^^^^^^^^
> >
> > last([]) -> H;
> > last([_|T]) -> last(T).

I like this one:

last([H|T]) ->
 case T of
  [] -> H;
  _  -> last(T)
 end;
last([]) -> 'whatever you want'.

Regards,

Roberto






More information about the erlang-questions mailing list