Last active
October 7, 2015 02:28
-
-
Save apaleslimghost/3090376 to your computer and use it in GitHub Desktop.
Cute one-line alternative to function pipe chaining in LiveScript
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
Object::go = (...funcs)->fold (|>), this, funcs | |
[1 to 10].go do | |
filter odd | |
map (^ 2) | |
fold1 (+) | |
#=>165 | |
#compare: | |
[1 to 10] | |
|> filter odd | |
|> map (^ 2) | |
|> fold1 (+) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment