UNPKG

crocks

Version:

A collection of well known Algebraic Datatypes for your utter enjoyment.

20 lines (15 loc) 484 B
/** @license ISC License (c) copyright 2016 original and current authors */ /** @author Ian Hofmann-Hicks (evil) */ var curry = require('../core/curry') var isArray = require('../core/isArray') var isFunction = require('../core/isFunction') function cons(x, m) { if(m && isFunction(m.cons)) { return m.cons(x) } else if(isArray(m)) { return [ x ].concat(m) } throw new TypeError('cons: List or Array required for second argument') } module.exports = curry(cons)