#!/usr/bin/env coffee

###########
# old way #
###########

# functions
a = (x) -> (g) -> g x * x
b = (x) -> (g) -> g x + x
c = (x) -> (g) -> g x * 100

# create the future
f = a 42

# pipeline it
f(b)(c)((x) -> console.log "result: #{x}")

# will print: 352800


############
# swag way #
############
a = (x) -> (g) -> g x       ; console.log "#{x}"
b = (g) -> (x) -> g x * x   ; console.log "#{x} * #{x}"
c = (g) -> (x) -> g x + x   ; console.log "#{x} + #{x}"
d = (g) -> (x) -> g x * 100 ; console.log "#{x} + 100"
e = (g) -> (x) -> g()       ; console.log "end"

# does nothing
e b c d e

# process, but show nothing
a(42) b c d e

# process and show
a(42) b c d (x) -> console.log "result: #{x}"