Last active
November 4, 2016 02:52
-
-
Save TheSeamau5/13ad73b1dce26f741cb5534f0efef393 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
-- Goal: In point-free style | |
mapReduce : (a -> b) -> (List b -> c) -> List a -> c | |
-- Simple | |
mapReduce mapper reducer list | |
= reducer (List.map mapper list) | |
-- Remove the last argument via composition | |
mapReduce mapper reducer | |
= reducer << List.map mapper | |
-- Flip direction of composition | |
mapReduce mapper reducer = | |
List.map mapper >> reducer | |
-- Make composition operator into a function | |
mapReduce mapper reducer = | |
(>>) (List.map mapper) reducer | |
-- Remove the last argument | |
mapReduce mapper = | |
(>>) (List.map mapper) | |
-- Use composition to remove the last argument | |
mapReduce = | |
(>>) << List.map | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment