[erlang-questions] why is the the output not a list

Ulf Wiger <>
Sat Sep 26 20:54:32 CEST 2015


> On 26 Sep 2015, at 14:44, Roelof Wobben <> wrote:
> 
> scan([Head | Rest], List_parse) when Head >= $0, Head =< $9 ->
>     digits(Head, Rest, List_parse);

If you want to pass the actual number as the first parameter to digits/3, you need to take Head - $0, and make corresponding changes to digits/3.

Also, presumably, you’ll want to multiply Number by 10 before adding the next digit?

Also, your code will return a reversed token list, although it doesn’t show here, since “1+1” is identical when reversed.

BR,
Ulf W

Ulf Wiger, Co-founder & Developer Advocate, Feuerlabs Inc.
http://feuerlabs.com





More information about the erlang-questions mailing list