Created
December 23, 2018 21:23
-
-
Save monorkin/b8fe4c86e74707a5b73889b81ea58123 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 g and f | |
h = f << g | |
# h is the same as -> x { (x * 2) + 2 } | |
[1, 2, 3].map(&h) # => [4, 6, 8] | |
# This is exactly the same as | |
[1, 2, 3].map(&g).map(&f) # => [4, 6, 8] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment