
I don't think list comprehension is the solution. What you want is a map.
Would this work?
data V = A | B | C
f :: [V] -> String
f l = flip map l $ \x -> case x of
A -> 'A'
B -> 'B'
C -> 'C'
main = print $ f [A,B,C,C,A]
2014-11-09 21:58 GMT-05:00 Donn Cave
I'm guessing this isn't supported, but might be worth asking - can I extend a list comprehension like ['A' | A <- s] to multiple values? Like,
data V = A | B | C
pv :: [V] -> [Char] pv [] = [] pv (A:x) = 'A':(pv x) pv (B:x) = 'B':(pv x) pv (_:x) = pv x
-- can that be a list comprehension, like
pv s = [ 'A' | A <- s -- ?? ]
thanks, Donn _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Viva Cila