16 Jul 2014, 16:07
Red-panda-icon_pragsmall

Taian Su (5 posts)

I know that


list = for x <- ‘1234’, do: [x]


=> [‘1’, ‘2’, ‘3’, ‘4’, ‘5’]

But at the end of Enum section of Ch 10, the example use


cards = for rank <- ‘23456789TJQKA’, suit <- ‘CDHS’, do: [suit, rank]


=> [‘C2’, ‘D2’, ‘H2’, ‘S2’, ‘C3’, ‘D3’, ‘H3’, ‘S3’, ‘C4’, ‘D4’, ‘H4’, ‘S4’, ‘C5’, ‘D5’, ‘H5’, ‘S5’, ‘C6’, ‘D6’,…]

I’m wondering why [char, char] becomes ‘C2’ but not [ [‘C’, ‘2’]… ] Thanks!

17 Jul 2014, 05:21
Red-panda-icon_pragsmall

Taian Su (5 posts)

I just find the answer at Ch. 11 that single quote string is a list of characters.

  You must be logged in to comment