rks
rks

Reputation: 451

Erlang: Strange chars in a generated list

Trying to generate a list through comprehension and at some point I start seeing strange character strings. Unable to explain their presence at this point (guessing the escape chars to be ASCII codes - but why?):

45> [[round(math:pow(X,2))] ++ [Y]|| X <- lists:seq(5,10), Y <- lists:seq(5,10)].                                     
[[25,5],
 [25,6],
 [25,7],
 [25,8],
 [25,9],
 [25,10],
 [36,5],
 [36,6],
 [36,7],
 "$\b","$\t","$\n",
 [49,5],
 [49,6],
 [49,7],
 "1\b","1\t","1\n",
 [64,5],
 [64,6],
 [64,7],
 "@\b","@\t","@\n",
 [81,5],
 [81,6],
 [81,7],
 "Q\b",
 [...]|...]

Upvotes: 3

Views: 336

Answers (1)

mpm
mpm

Reputation: 3584

In Erlang all strings are just list of small integers (like chars in C). And shell to help you out a little tries to interpret any list as printable string. So what you get are numbers, they are just printed in a way you would not expect.

If you would like to change this behaviour you can look at this answer.

Upvotes: 5

Related Questions