Skip to content

Commit

Permalink
Fix for issue raganwald#24 - double
Browse files Browse the repository at this point in the history
  • Loading branch information
vanhelgen committed Oct 12, 2013
1 parent 230589c commit 8936f55
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions manuscript/markdown/Functions/combinators.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,25 +54,25 @@ Let's say we have:
return number + 1
}

function double (number) {
function doubleOf (number) {
return number * 2
}

With `compose`, anywhere you would write

function doubleOfAddOne (number) {
return double(addOne(number))
return doubleOf(addOne(number))
}

You could also write:

var doubleOfAddOne = compose(double, addOne);
var doubleOfAddOne = compose(doubleOf, addOne);

This is, of course, just one example of many. You'll find lots more perusing the recipes in this book. While some programmers believe "There Should Only Be One Way To Do It," having combinators available as well as explicitly writing things out with lots of symbols and keywords has some advantages when used judiciously.

### a balanced statement about combinators

Code that uses a lot of combinators tends to name the verbs and adverbs (like `double`, `addOne`, and `compose`) while avoiding language keywords and the names of nouns (like `number`). So one perspective is that combinators are useful when you want to emphasize what you're doing and how it fits together, and more explicit code is useful when you want to emphasize what you're working with.
Code that uses a lot of combinators tends to name the verbs and adverbs (like `doubleOf`, `addOne`, and `compose`) while avoiding language keywords and the names of nouns (like `number`). So one perspective is that combinators are useful when you want to emphasize what you're doing and how it fits together, and more explicit code is useful when you want to emphasize what you're working with.

### function decorators {#decorators}

Expand Down

0 comments on commit 8936f55

Please sign in to comment.