Skip to content

Instantly share code, notes, and snippets.

@monorkin
Created December 23, 2018 21:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save monorkin/29d85038e17bc96ccc354284c130765b to your computer and use it in GitHub Desktop.
Save monorkin/29d85038e17bc96ccc354284c130765b to your computer and use it in GitHub Desktop.
f = -> x { x + 2 }
g = -> x { x * 2 }
# h is the composition of f and g
h = f >> g
# h is the same as -> x { (x + 2) * 2 }
[1, 2, 3].map(&h) # => [6, 8, 10]
# This is exactly the same as
[1, 2, 3].map(&f).map(&g) # => [6, 8, 10]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment