Skip to content

Instantly share code, notes, and snippets.

@ivenmarquardt
ivenmarquardt / paralk.js
Last active October 18, 2016 10:06
Paramorphism, extended catamorphism, fold, iteration
const paralk = f => acc => xs => {
const next = (acc, [head, ...tail]) => head === undefined
? acc
: f(acc) (head, tail, acc => next(acc, tail));
return next(acc, xs);
};
const drop = n => paralk(acc => (x, tail, k) => acc.length + 1 === n ? tail : (acc.push(x), k(acc))) ([]);