[erlang-questions] List comprehension puzzler

Dan Gudmundsson dangud@REDACTED
Sun Sep 18 19:03:24 CEST 2016


What happens when you write it out?

io:format("~w~n",[S]).
[49,50,51,97,52,53,54]

Hmm a strange list of integers appears.

A string in erlang is a (normal) list of characters/unicode codepoints
which are represented by their integer value.


On Sun, Sep 18, 2016 at 6:56 PM <lloyd@REDACTED> wrote:

> Hello,
>
> Now this I would not expect:
>
> 4> S = "123a456".
> "123a456"
>
> 5> is_integer(S).
> false
>
> 6> [is_integer(I) || I <- S].
> [true,true,true,true,true,true,true]
>
> Please tell me what I don't understand.
>
> Many thanks,
>
> LRP
>
>
> *********************************************
> My books:
>
> THE GOSPEL OF ASHES
> http://thegospelofashes.com
>
> Strength is not enough. Do they have the courage
> and the cunning? Can they survive long enough to
> save the lives of millions?
>
> FREEIN' PANCHO
> http://freeinpancho.com
>
> A community of misfits help a troubled boy find his way
>
> AYA TAKEO
> http://ayatakeo.com
>
> Star-crossed love, war and power in an alternative
> universe
>
> Available through Amazon or by request from your
> favorite bookstore
>
>
> **********************************************
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160918/80d87d90/attachment.htm>


More information about the erlang-questions mailing list