pahanix & IT

yet another passionate programmer

Notes &

Functional Javascript

Functional is a library for functional programming in JavaScript. It defines the standard higher-order functions such as mapreduce (aka foldl), and select (aka filter). It also defines functions such as curryrcurry, and partial for partial function application; and composeguard, and until for function-level programming. And all these functions accept strings, such as 'x -> x+1''x+1', or '+1' as synonyms for the more verbose function(x) {return x+1}.

Functional supports higher-order programming:

map('x*x', [1,2,3,4])
  → [1, 4, 9, 16]
select('>2', [1,2,3,4])
  → [3, 4]
reduce('x*2+y', 0, [1,0,1,0])
  → 10
map(guard('2*', not('%2')), [1,2,3,4])
  → [1, 4, 3, 8]

Ports: String#to_proc (Ruby; Reginald Braithwaite), Erlang (Debasish Ghosh), Dojo (Eugene Lazutkin).

Filed under javascript