[erlang-questions] How to get strings instead of ints out of this code?

Lev Walkin vlm@REDACTED
Wed May 7 20:50:44 CEST 2008


Jarrod Roberson wrote:
> Erlang (BEAM) emulator version 5.6 [smp:2] [async-threads:0]
> 
> Eshell V5.6  (abort with ^G)
> 1> [A,B|T] = "abcdefg".
> "abcdefg"
> 2> A.
> 97
> 3> B.
> 98
> 4> T.
> "cdefg"
> 
> I know _why_ A. and B. print out as ints and why T. prints out as a 
> string of characters, how do I get A and B to print out as characters?

Try [A]. There's no such thing as an individual character in Erlang.
Essentially, you have to create a string of 1 character to have
it printed as a character (sort of).

Alternatively, you could just convert it to atom and print:

1> list_to_atom([98]).
b
2>

-- 
Lev Walkin



More information about the erlang-questions mailing list