Noob - Getting Started Infinte Loop?

Romain Lenglet rlenglet@REDACTED
Wed Aug 30 13:41:35 CEST 2006


fbg111 wrote:
> > listlen([First|TheRest]) -> 1 + listlen([TheRest]).

You are creating a (non-empty) list at every step. Therefore your 
code recurses infinitely. This code should be:
listlen([First|TheRest]) -> 1 + listlen(TheRest).

TheRest (the tail of the list) is already a list.

-- 
Romain LENGLET



More information about the erlang-questions mailing list