In Haskell I have a list that looks like this:
[[["PersonA"],["AddressA"]],[["PersonB"],["AddressB"]],[["PersonC"]]]
and I need the lists within my list that have length=2, i.e. the people that I know the address of. In this case, I would want:
[["PersonA"],["Address"]]
and
[["PersonB"],["Address"]]
and I would not want PersonC because I don't have his address.
I was thinking about something like:
myList = [[["PersonA"],["123456789"]],[["PersonC"],["987654321"]],[["PersonE"]]]
main :: IO ()
main = do
map (\x -> if length x == 2 print x else print "") myList
(print is just an example, I will need to work with them later)
But this returns a
Couldn't match expected type ‘IO ()’ with actual type ‘[IO ()]’
error on line 5.
Any idea how to do that?
Thanks
Aucun commentaire:
Enregistrer un commentaire