02 Currying

Exercise A

// words :: String -> [String]
const words = str => split(' ', str);

Refactor to remove all arguments by partially applying the function.

const words = split(' ')

Exercise B

// filterQs :: [String] -> [String]
const filterQs = xs => filter(x => x.match(/q/i), xs);

Refactor to remove all arguments by partially applying the functions.

As you can see, it is much more concise and sexy.

const filterQs = filter(match(/q/i));

Exercise C

Considering the following functions.

const keepHighest = (x, y) => (x >= y ? x : y);

// max :: [Number] -> Number
const max = xs => reduce((acc, x) => (x >= acc ? x : acc), -Infinity, xs);

Refactor max to not reference any arguments using the helper function keepHighest.

const max = reduce(keepHighest, -Infinity);

An existing line!