Recursive list comprehension

Vlad Dumitrescu vlad_dumitrescu@REDACTED
Fri Jan 13 11:58:21 CET 2006


Hi,

----- Original Message ----- 
From: "Joel Reymont" <joelr1@REDACTED>
> trans([{st, r, []}]) ->
>      none;
> trans(S) ->
>      [{[M1] ++ M2, C1 + C2} || {S1, M1, C1} <- move(S), {M2, C2} <-
> trans(S1)].


Changing your trans function to

trans({st, _, []}) ->
     [{[], 0}];
trans(S) ->
    [{[M1] ++ M2, C1 + C2} || {S1, M1, C1} <- move(S), {M2, C2} <-
trans(S1)].

makes the result be

(emacs@REDACTED)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]}]]

which I didn't check if it's correct, but looks like a step forward!

regards,
/Vlad



More information about the erlang-questions mailing list