Tagged as challenge
Written on 2018-01-30
Implement the following combinators, high-order functions that are usually composed together. (Here we specify the type signatures in Haskell-like notation.)
(constantly x), a function which takes an argument
xand produces a unary function which always returns
yeswhich always returns a true value, and
nowhich always returns a false value.
(complement f), a function which takes a function returning a Boolean, and produces another function which does the same but with the Boolean inverted.
(conjunction f g)which returns a function which takes an argument and returns true iff both
gare satisfied by
(disjunction f g)which is like
conjunctionbut checks iff either
gare satisfied by the input.
One should note the similarity between these functions and some of the basic unary and binary Boolean predicates.
Write out the type signature of each of the above functions.
Implement Fizz Buzz using these combinators.