[erlang-questions] List comprehension puzzler

Lloyd R. Prentice lloyd@REDACTED
Tue Sep 20 06:41:47 CEST 2016


Hi Hernando,

I came up with almost the exact same code after Dan Gudmunsson pointed out the error  of my ways.

Many thanks for the solution.

Best wishes,

Lloyd

Sent from my iPad

> On Sep 19, 2016, at 11:01 PM, Hernando Gisinger <hgisinger@REDACTED> wrote:
> 
> Hello
> 
> 1> IsDigit = fun(C) -> C >= $0 andalso C =< $9 end.
> #Fun<erl_eval.6.52032458>
> 2> S = "123a456".
> "123a456"
> 3> [IsDigit(I) || I <- S].   
> [true,true,true,false,true,true,true]
> 
> 
> 2016-09-18 13:56 GMT-03:00 <lloyd@REDACTED>:
>> 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/20160920/3bd3a6fe/attachment.htm>


More information about the erlang-questions mailing list