Trying to understand tuples and lists
Hal Daume III
hdaume at ISI.EDU
Wed Nov 5 07:14:43 EST 2003
Based on this and your previous post, I think you're not understanding
what "<-"/"do" are for. I think you'll be better off forgetting them
completely and using 'let/in' for now.
let (x,y) = head [...]
is what you want.
On Wed, 5 Nov 2003, Karthik Kumar wrote:
> I have a list of tuples ( characters and numbers ) .
> say, [('a', 1), ('b', 2)]
> I want to extract 'a' and 1 separately .
> (x,y) <- head [('a', 1), ('b', 2)]
> This doesnt work but my idea is to get x contain the value 'a' and y
> contain the value 1 as the first tuple in the list.
> Which is the right way of doing this. Thanks for your help.
> Do you Yahoo!?
> Protect your identity with Yahoo! Mail AddressGuard
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
Hal Daume III | hdaume at isi.edu
"Arrest this man, he talks in maths." | www.isi.edu/~hdaume
More information about the Haskell-Cafe