Created
July 23, 2015 13:17
-
-
Save amar47shah/3b9b87400742e97eba80 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
-- Derivation of (f .) . g == f (g x y) | |
-- Examples | |
countWhere = (length .) . filter | |
duplicate = (concat .) . replicate | |
concatMap = (concat .) . map | |
-- Could also be written | |
countWhere p xs = length (filter p xs) | |
duplicate n xs = concat (replicate n xs) | |
concatMap f xs = concat (map f xs) | |
-- Reverse derivation | |
-- (f .) . g | |
-- == \x -> ((f .) . g) x | |
-- == \x -> (f .) (g x) | |
-- == \x -> f . (g x) | |
-- == \x y -> (f . (g x)) y | |
-- == \x y -> f ((g x) y) | |
-- == \x y -> f (g x y) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment