Possible bug using funs

Fredrik Linder fredrik.linder@REDACTED
Wed Jul 17 00:44:35 CEST 2002


Hi, I get the following error when writing a fun:

The only differense (as I can see) is the order of the two clauses in the
funs; T2 has the empty list test as its first clause while T1 has the empty
list test as its last clause:

17> T2=fun([],[],Acc,Cont)->lists:reverse(Acc);
([H1|T1],[H2|T2],Acc,Cont)->io:format("~w~n",[Acc]),Cont(T1,T2,[{H1,H2}|Acc]
,Cont) end.
#Fun<erl_eval.3.17583228>
18> T2([1,2],[1,2],[],T2).
[]
[{1,1}]
[{1,1},{2,2}]
19>
T1=fun([H1|T1],[H2|T2],Acc,Cont)->io:format("~w~n",[Acc]),Cont(T1,T2,[{H1,H2
}|Acc],Cont); ([],[],Acc,Cont)->lists:reverse(Acc) end.
#Fun<erl_eval.3.17583228>
20> T1([1,2],[1,2],[],T1).
[]
[{1,1}]
** exited: {{illegal_pattern,{cons,1,{var,1,'H1'},{var,1,'T1'}}},
            [{erl_eval,expr,3}]} **
21>

I'm using: Erlang 5.1/OTP R8B

/Fredrik





More information about the erlang-questions mailing list