Skip to content

Instantly share code, notes, and snippets.

@gkz
Forked from apaleslimghost/go.ls
Created July 12, 2012 05:00
Show Gist options
  • Select an option

  • Save gkz/3095927 to your computer and use it in GitHub Desktop.

Select an option

Save gkz/3095927 to your computer and use it in GitHub Desktop.
Cute one-line alternative to function pipe chaining in LiveScript
Object::go = -> fold (|>), this, &
[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