Lists search by first element of a tuple
Peter Lund
erlang@REDACTED
Wed Feb 8 09:41:48 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