Skip to content

Instantly share code, notes, and snippets.

View lanceharper's full-sized avatar

Lance Harper lanceharper

View GitHub Profile
@lanceharper
lanceharper / fold.js
Last active December 3, 2015 01:06 — forked from kpuputti/fold.js
Functional acrobatics using folds in JavaScript.
/*eslint-env es6 */
// Inspired by the paper "A tutorial on the universality and
// expressiveness of fold" by Graham Hutton (available at
// http://www.cs.nott.ac.uk/~gmh/fold.pdf), implementing some generic
// list handling functions in JavaScript in terms of `fold`.
// Personally I had an enlightnening moment when I realised the
// beautiful interplay of cons lists and foldr during the FP101x
// Haskell course. JavaScript's syntax doesn't make this very apparent