export const True = a => _ => a
Check out my combinators-js library if you are interested in combinatory logic. A combinator is just a higher order function that uses only function application and earlier defined combinators to define a result from its arguments. Most of the functions declared here can be defined very simply in terms of combinators.
True
takes 2 arguments and returns the first. This is the K combinator
True('first')('second') // => 'first'`
export const True = a => _ => a
False
takes 2 arguments and returns the second. This is the KI combinator
False('first')('second') // => 'second'
export const False = _ => a => a
If
takes a predicate and two values, returning the first value if the predicate is True and the second if the predicate is False. This is the I** combinator
If(True)('then')('else') // => 'then'
If(False)('then')('else') // => 'else'
export const If = a => b => c => a(b)(c)
export const and = a => b => a(b)(a)
export const or = a => b => a(a)(b)
export const not = a => b => c => a(c)(b)
export const xor = a => b => c => d => a(b(d)(c))(b(c)(d))