Skip to content

Instantly share code, notes, and snippets.

@buzzdecafe
Created March 17, 2018 15:14
Show Gist options
  • Save buzzdecafe/54e7f591e7023abc0c806409d27b5df7 to your computer and use it in GitHub Desktop.
Save buzzdecafe/54e7f591e7023abc0c806409d27b5df7 to your computer and use it in GitHub Desktop.
const NIL = Symbol('~~NIL~~');
const isNil = x => typeof x === 'symbol' && x.toString() === NIL.toString();
const pair = (a, b) => ({
fst: function* () { yield a; },
snd: function* () { yield b; },
[Symbol.iterator]: function* () { yield a; (b[Symbol.iterator] ? yield* b : yield b); }
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment