[Haskell-beginners] Problem specifying fst in tuple from list in filter
Angus Comber
anguscomber at gmail.com
Thu Jan 2 15:52:49 UTC 2014
I can generate a tuple of (index,character) like this:
zip [0..] ['A'..'Z']
To filter on an element in the list I can do:
filter (== (0,'A')) $ zip [0..] ['A'..'Z']
> [(0,'A')]
But that is very basic, I really want to select on index value (ie first
item in pair). How do I specify the first part of tuple:
filter (fst == 0) $ zip [0..] ['A'..'Z']
this doesn't work.
Couldn't match expected type `(a1, Char) -> Bool'
with actual type `Bool'
In the first argument of `filter', namely `(fst == 0)'
In the expression: filter (fst == 0)
In the expression: filter (fst == 0) $ zip [0 .. ] ['A' .. 'Z']
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20140102/ea595186/attachment.html>
More information about the Beginners
mailing list