W4D4: Off-day


(literally) SIIIIIIIICK food poisoning/stomach flu. Woke up this morning to explosive diarrhea and a bit of yakking. Richard had left after waiting for me for a bit, and I promised to make his lunch for tomorrow for the inconvenience

On the plus side I got to take the day off! I spent the day catching up on my blog, reviewing what we've learned, and playing a bit lot of Starcraft.
Not good... I think I'm starting to get hooked -- ahhh, just like the good old days



What we were SUPPOSED to do today:
1. Toy Problem

Compose, Pipe


Implement the functions compose and pipe`.

Compose

Compose should return a function that is the composition of a list of functions of arbitrary length. Each function is called on the return value of the function that follows.
You can think of compose as moving right to left through its arguments.

Example

var greet = function(name){ return 'hi: ' + name;}
var exclaim = function(statement) { return statement.toUpperCase() + '!';}

var welcome = compose(greet, exclaim);
welcome('phillip'); //=> 'hi: PHILLIP!'

Pipe:

Pipe composes a series of functions and returns the resulting function. Each function is called on the return value of the preceding function.
You can think of pipe as moving left to right through its arguments.

Example

var add2 = function(number){ return number + 2; }
var multiplyBy3 = function(number){ return number * 3; }

pipe(add2, multiplyBy3)(5) //=> 21
pipe(add2, multiplyBy3, multiplyBy3)(5) //=> 63
HINT: You should use the functions reduce() and reduceRight() in your solutions.

2. Continue pair programming on Web Historian

3. Townhall

No comments:

Post a Comment