
Am a bit stuck here,... please, what is wrong with this? checkNode :: String -> [String] -> Bool checkNode s nodes = [s == node | node <- nodes ] src/me.hs:3:4: Couldn't match expected type `Bool' with actual type `[t0]' [1 of 1] Compiling Main ( src/me.hs, interpreted ) In the expression: [s == node | node <- nodes] Failed, modules loaded: none. In an equation for `checkNode': checkNode s nodes = [s == node | node <- nodes] thanks, Miro

On Sat, Jun 16, 2012 at 8:39 PM, miro
Am a bit stuck here,... please, what is wrong with this?
checkNode :: String -> [String] -> Bool checkNode s nodes = [s == node | node <- nodes ]
This is going to return a *list* of Bools, one per String in the original list. -- brandon s allbery allbery.b@gmail.com wandering unix systems administrator (available) (412) 475-9364 vm/sms

What you want is probably checkNode :: String -> [String] -> Bool checkNode s nodes = and (map (==s) nodes) which returns True iff all nodes equal s.
Am a bit stuck here,... please, what is wrong with this?
checkNode :: String -> [String] -> Bool checkNode s nodes = [s == node | node <- nodes ]
src/me.hs:3:4: Couldn't match expected type `Bool' with actual type `[t0]' [1 of 1] Compiling Main ( src/me.hs, interpreted ) In the expression: [s == node | node <- nodes] Failed, modules loaded: none. In an equation for `checkNode': checkNode s nodes = [s == node | node <- nodes]
thanks, Miro

Thank you! Miro On 6/17/12 9:08 AM, Morel Pisum wrote:
What you want is probably
checkNode :: String -> [String] -> Bool checkNode s nodes = and (map (==s) nodes)
which returns True iff all nodes equal s.
Am a bit stuck here,... please, what is wrong with this?
checkNode :: String -> [String] -> Bool checkNode s nodes = [s == node | node<- nodes ]
src/me.hs:3:4: Couldn't match expected type `Bool' with actual type `[t0]' [1 of 1] Compiling Main ( src/me.hs, interpreted ) In the expression: [s == node | node<- nodes] Failed, modules loaded: none. In an equation for `checkNode': checkNode s nodes = [s == node | node<- nodes]
thanks, Miro
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
participants (3)
-
Brandon Allbery
-
miro
-
Morel Pisum