this question is from Haskell newbies.
I am writing the code below to check the number of True in the list, and if it even has a True number, return True , otherwise return `False '.
xor = foldr xor' False where xor' True True = False xor' False False = False xor' _ _ = True
However, I found a few snippets of code below, and it seems that it can do the same. Here is the code:
xor :: [Bool] -> Bool xor = odd . length . filter id
But I just donโt know how id works in the above code, can anyone help me?
source share