[erlang-questions] Question on pattern matching from Joe's book

David Mercer <>
Fri Jul 27 22:55:59 CEST 2007

I don't have the book, but the string "cat" is stored as the list [99, 97,
116].  The shell is nice enough to print lists of digits that look like
strings as strings.  [H|T] = "cat" is equivalent to [H|T] = [99, 97, 116],
so H is 99 and T is [97, 116], which the shell thinks is a string, so
outputs "at".  Does this answer your question?


-----Original Message-----
[mailto:] On Behalf Of Prakash
Sent: Friday, July 27, 2007 15:16
Subject: [erlang-questions] Question on pattern matching from Joe's book

On page 43 of the pdf book, under section 2.12 "Pattern Matching
again", the second-to-last example: [H T] "cat" Succeeds H ->99, T

Why is the value assigned to T-> "at" and not "97116"?

erlang-questions mailing list


More information about the erlang-questions mailing list