Summing a number to the terms of a list
Vlad Dumitrescu
vlad_dumitrescu@REDACTED
Tue Aug 12 19:58:26 CEST 2003
Hi,
----- Original Message -----
From: "Jilani Khaldi" <jilani.khaldi@REDACTED>
> Why this code gives me these different results?
>
> A=[1,2,3].
> sumit:sum_me(A,100).
> "efg"
>
> sumit:sum_me(A,200).
> "\311\312\313"
>
> sumit:sum_me(A,300).
> [301,302,303] -- as I expected.
In the first two cases, the resulting lists contain small integers and when
printing those, the shell assumes they are strings. Erlang strings are
indistinguishable from arbitrary lists that happen to contain only small
integers (<255). Try in the shell to type
>[101, 102, 103].
regards,
Vlad
More information about the erlang-questions
mailing list