Lists search by first element of a tuple

Peter Lund peterl@REDACTED
Wed Feb 8 09:40:11 CET 2006


Ulf Wiger wrote:

> I think that's about as good as it gets, except perhaps for:
>
> [X || {{1,_},_}=X <- L]
>
Interesting matching!

But why does not [X || X={{1,_},_} <- L] work when [X || {{1,_},_}=X <- 
L] works?    (tested on R9C )

1> [X||{1,_}=X<-[{2,3},{1,4},b,{1,7},c]].
[{1,4},{1,7}]
2> [X||X={1,_}=<-[{2,3},{1,4},b,{1,7},c]].
** 1: variable '_' is unbound **

/Peter



More information about the erlang-questions mailing list