Fun with Functions!


Details
Functional programming is all about...programming with functions! But just how much of a program can you actually write with just...functions?
Find out how far you can go in this fun, interactive series of exercises, each one more challenging than the last.
Bring a laptop and your favorite programming language (Javascript, Haskell, Clojure, Scala, PureScript, Haxe, or whatever!) and prepare to work through a series of problems that will push your skills in functional thinking and functional composition to the next level.
There's only ONE rule, but it's an important one: all your values must be functions! Not "programming functions", but "math functions", which means you must ensure the following:
Totality Requirement: For every element in the function's domain, the function must return an element in the function's codomain. For example, a function from booleans to booleans must be able to handle all possible boolean values. In dynamically typed programming languages, this means you must handle all possible inputs! No throwing exceptions, since that would violate the totality requirement.
Whoa, think you can handle that? Sure you can, although practice will make perfect!
To get you started, here's is the first exercise, and a corresponding solution in JavaScript:
- Develop a function-based model for boolean values, which may be either "true" or "false".
var True = function(ifTrue, ifFalse) { return ifTrue; }
var False = function(ifTrue, ifFalse) { return ifFalse; }
Full Exercises (https://gist.github.com/jdegoes/9d6242bda4a690d81088)

Fun with Functions!