Recursive list comprehension

Vlad Dumitrescu vlad_dumitrescu@REDACTED
Fri Jan 13 12:22:22 CET 2006


> I will rephrase it a bit. Obviously my original version was 
> wrong as trans is never given a list. That would mean to me 
> that trans would never terminate. Why does it return [] then?

It terminates because when it gets an argument of [{st, r, []}], the
comprehension is applied and it returns [], of course.
 
> Ignoring the position of the flash light makes no difference. 
> This still works:
> 
> trans({st, r, []}) ->
>      [{[], 0}];

This is because it can't be on the left side without any toy, unless it is
allowed to throw it to the other side after the batteries are dead :-)

/Vlad



More information about the erlang-questions mailing list