I'm having trouble with erlang converting listed numbers to characters whenever none of the listed items could not also be representing a character.
I am writing a function to separate all the numbers in a positive integer and put them in a list, for example: digitize(123)
should return [1,2,3]
and so on.
The following code works fine, except when the list only consist of 8's and/or 9's:
digitize(_N) when _N =:= 0 -> [];
digitize(_N) when _N > 0 -> _H = [_N rem 10], _T = digitize(_N div 10), _T ++ _H.
For example: Instead of digitize(8)
returning [8]
, it gives me the nongraphic character "\b"
and digitize(89)
returns "\b\t"
. This is only for numbers 8 and 9 and when they're put alone inside the list. digitize(891)
will correctly return [8,9,1]
for example.
I am aware of the reason for this but how can I solve it without altering my result? (ex: to contain empty lists inside the result like [[],[8]]
for digitize(8)
)