Skip to content

Instantly share code, notes, and snippets.

@TheSeamau5
Last active Nov 4, 2016
Embed
What would you like to do?
-- 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