Created
December 23, 2018 21:13
-
-
Save monorkin/29d85038e17bc96ccc354284c130765b to your computer and use it in GitHub Desktop.
This file contains 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
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