crocks
Version:
A collection of well known Algebraic Datatypes for your utter enjoyment.
20 lines (15 loc) • 453 B
JavaScript
/** @license ISC License (c) copyright 2016 original and current authors */
/** @author Ian Hofmann-Hicks (evil) */
var curry = require('../core/curry')
var isFunction = require('../core/isFunction')
// Flip (Cardinal)
// flip :: (a -> b -> c) -> b -> a -> c
function flip(f, x, y) {
if(!isFunction(f)) {
throw new TypeError(
'flip: Function required for first argument'
)
}
return curry(f)(y, x)
}
module.exports = curry(flip)