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

David Mercer dmercer@REDACTED
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?

David

-----Original Message-----
From: erlang-questions-bounces@REDACTED
[mailto:erlang-questions-bounces@REDACTED] On Behalf Of Prakash
Swaminathan
Sent: Friday, July 27, 2007 15:16
To: erlang-questions@REDACTED
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
->"at".

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

thanks,
--Prakash
_______________________________________________
erlang-questions mailing list
erlang-questions@REDACTED
http://www.erlang.org/mailman/listinfo/erlang-questions




More information about the erlang-questions mailing list