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

Ulf Wiger ulf@REDACTED
Sat Sep 26 20:54:32 CEST 2015

> On 26 Sep 2015, at 14:44, Roelof Wobben <r.wobben@REDACTED> 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.

Ulf W

Ulf Wiger, Co-founder & Developer Advocate, Feuerlabs Inc.

More information about the erlang-questions mailing list