Comprehending List Comprehensions

Peter Caven <>
Mon Nov 26 13:22:14 CET 2001


Hello,
I am at the early stages of learning Erlang and I've encountered what seems
to be strange behaviour in list comprehensions. The expression:

[{Token} || {Start, Length} <- [{1,1},{2,2},{4,2}], Token <-
string:substr("1+1-2", Start, Length)]

returns:

[{49},{43},{49},{45},{50}]

when I expected it to return:

[{"1"},{"+1"},{"-2"}]

Can someone please point out where my mistake is?

Thanks,
Peter.




More information about the erlang-questions mailing list