Skip to content

Commit

Permalink
added missing function buildPairs
Browse files Browse the repository at this point in the history
  • Loading branch information
Dobiasd committed Nov 9, 2013
1 parent e971971 commit 6240f1b
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,21 @@ l = map ((^)2) [1..10]

Sure, what is more readable/pretty is also a matter or habit/taste. But
beside the terseness there come other benefits with the abstract separation
of the control structure, e.g. if you want to decide from the outside what
to do with the values:
of the control structure, e.g. if you want to decide [from the outside]
(http://share-elm.com/sprout/527e00f0e4b06194fd2d191f) what to do with the
values:

```haskell
buildPairs l f = zip l <| map f l
l1 = buildPairs [1..5] ((^)2)
l2 = buildPairs [1..5] sqrt
l3 = buildPairs [1..5] ((*)2)
l4 = buildPairs [1..5] ((+)1)
```

You can also decide which direction you prefer to read:
You can also decide [which direction]
(http://share-elm.com/sprout/527e0130e4b06194fd2d1920) you prefer to read:

```haskell
la = map ((^)2) [1..10] -- normal function application
lb = ((^)2) `map` [1..10] -- infix notation
Expand Down

0 comments on commit 6240f1b

Please sign in to comment.