Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
FP for MooTools: decorators, preconditions, currying, arity dispatch, etc... (github.com/shiftspace)
2 points by swannodette on Oct 25, 2009 | hide | past | favorite | 1 comment


In conjunction with the Promises library (http://github.com/ShiftSpace/promises) you can also do things like the following:

  var sum = $arity(
    function(a) { return a; },
    function(a, b) { return add(a, b.first()); }
  );
  var lazyValues = [$lazy(), $lazy(), $lazy()];
  var sum = $reduce(sum, lazyValues);

  lazyValues[0].setValue(10);
  lazyValues[1].setValue(2);
  lazyValues[2].setValue(3);

  sum.value(); // 15




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: