Created
November 20, 2012 21:08
-
-
Save trobertson/4121140 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- adds up how many zeros are in the elements of a list | |
cz :: Show a => [a] -> Int | |
cz = sum . map length . map (filter (=='0')) . map show | |
-- the (.) means function composition, and lets you exclude the | |
-- variable being operated on. so: | |
-- f . g == f (g (x)) | |
cz' :: Show a => [a] -> Int | |
cz' s = sum (map length (map (filter (=='0')) (map show s))) | |
-- to make it more readable: | |
cz'' :: Show a => [a] -> Int | |
cz'' s = sum c | |
where c = map length b | |
b = map (filter (=='0')) a | |
a = map show s |
wut.... is this ur 0nly g1st????
i iz d1sapp01nt.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
GNARLY!!!!!!!!!!!!!!!!