Recursive list comprehension

Joel Reymont <>
Fri Jan 13 12:11:47 CET 2006


On Jan 13, 2006, at 10:58 AM, Vlad Dumitrescu wrote:

> ----- Original Message -----
> From: "Joel Reymont" <>
>> trans([{st, r, []}]) ->
>>      none;
> [...]
> Changing your trans function to
>
> trans({st, _, []}) ->
>      [{[], 0}];
> [...]
> makes the result be
>
> ()41> zurg:solution().
> [[{r,[buzz,woody]},{l,buzz},{r,[hamm,rex]},{l,woody},{r, 
> [buzz,woody]}],
>  [{r,[buzz,woody]},{l,woody},{r,[hamm,rex]},{l,buzz},{r, 
> [buzz,woody]}]]

The correct results according to SWI-Prolog:

M = [r([buzz, woody]), l(buzz), r([hamm, rex]), l(woody), r([buzz,  
woody])] ;

M = [r([buzz, woody]), l(woody), r([hamm, rex]), l(buzz), r([buzz,  
woody])] ;

The above version does not take into account where the flashlight is  
but I suppose it's always with the toys so it does not matter. It  
still produces correct results.

So the issue is that trans never terminates in my original version?

Why would it return []?

I'm baffled and can't see why just ignoring the position of the  
flashlight would make such a huge difference in the Erlang version :-(.

	Thanks, Joel

--
http://wagerlabs.com/








More information about the erlang-questions mailing list