Skip to content

Instantly share code, notes, and snippets.

@ronaldronson
Created January 21, 2014 13:02
Show Gist options
  • Save ronaldronson/8539611 to your computer and use it in GitHub Desktop.
Save ronaldronson/8539611 to your computer and use it in GitHub Desktop.
CoffeeScript fun
Function::some = (n) -> that = @; (a...) -> that.apply this, a.slice 0, n
# loger
log = (a...) -> console.log a.join " -> "
# math
mult = (a) -> a * a
# possition
odd = (k) -> k % 2
even = (k) -> !odd k
# agr's
nsarg = (n) -> () -> arguments[n]
last = (a...) -> a.pop()
# comparetion
less = (than) -> (x) -> than > x
greater = (than) -> (x) -> than < x
[0..100]
.map( nsarg 1 )
.map( mult )
.filter( even )
.filter( less 100 )
.filter( greater 10 )
.forEach( log.some 2 )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment