Skip to content

Instantly share code, notes, and snippets.

@TheSeamau5
Last active November 4, 2016 02:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TheSeamau5/13ad73b1dce26f741cb5534f0efef393 to your computer and use it in GitHub Desktop.
Save TheSeamau5/13ad73b1dce26f741cb5534f0efef393 to your computer and use it in GitHub Desktop.
-- 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