2diuna
Last Updated: February 25, 2016
·
1.588K
· runexec
81609937c20aeab3598aea56f1f4f022

JavaScript is really ugly Lisp

It's true, and now there's a bad ass library to improve the functional experience. http://osteele.com/sources/javascript/functional/

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]

Functional is a library for functional programming in JavaScript. It defines the standard higher-order functions such as map, reduce (aka foldl), and select (aka filter). It also defines functions such as curry, rcurry, and partial for partial function application; and compose, guard, 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}.
Say Thanks
Respond