Skip to content

Instantly share code, notes, and snippets.

@PhyrexTsai
Created April 22, 2016 03: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 PhyrexTsai/d384e824932eed3dcf471d48b0548c2a to your computer and use it in GitHub Desktop.
Save PhyrexTsai/d384e824932eed3dcf471d48b0548c2a to your computer and use it in GitHub Desktop.
Foldr.md

Foldr

a. Use foldr to define map f. To avoid confusion, please rename it as myMap.

myMap :: (a->b)->[a]->[b]
myMap f = foldr ...

b. What does the following higher-order function, pipeline, do?

pipeline = map . foldr (.) id

where id x = x is the identity function. Note that (.) makes . a prefix function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment