Skip to content

Instantly share code, notes, and snippets.

View meChrisReed's full-sized avatar

Chris Reed meChrisReed

View GitHub Profile
@meChrisReed
meChrisReed / recur.js
Last active June 16, 2017 19:08 — forked from CreaturePhil/recur.js
A Million Ways to Fold in JS Notes
// from http://forwardjs.com/university/a-million-ways-to-fold-in-js
'use strict'
const first = xs => xs[0]
const rest = xs => xs.slice(1)
const concat = (xs1, xs2) => [ ...xs1, ...xs2 ]
// recursion
const sum = xs => xs.length === 0 ?