You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: source_md/higher-order-functions.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -130,7 +130,7 @@ From the definition of sections, `(-4)` would result in a function that takes a
130
130
However, for convenience, `(-4)` means minus four.
131
131
So if you want to make a function that subtracts 4 from the number it gets as a parameter, partially apply the `subtract` function like so: `(subtract 4)`.
132
132
133
-
What happens if we try to just do `multThree 3 4` in GHCi instead of binding it to a name with a *let* or passing it to another function?
133
+
What happens if we try to just do `multThree 3 4` in GHCi instead of binding it to a name with a `let` or passing it to another function?
134
134
135
135
```{.haskell:hs}
136
136
ghci> multThree 3 4
@@ -495,7 +495,7 @@ To make a lambda, we write a `\` (because it kind of looks like the greek letter
495
495
After that comes a `->` and then the function body.
496
496
We usually surround them by parentheses, because otherwise they extend all the way to the right.
497
497
498
-
If you look about 5 inches up, you'll see that we used a *where* binding in our `numLongChains` function to make the `isLong` function for the sole purpose of passing it to `filter`.
498
+
If you look about 5 inches up, you'll see that we used a `where` binding in our `numLongChains` function to make the `isLong` function for the sole purpose of passing it to `filter`.
499
499
Well, instead of doing that, we can use a lambda:
500
500
501
501
```{.haskell:hs}
@@ -960,7 +960,7 @@ Many times, a point free style is more readable and concise, because it makes yo
960
960
You can take simple functions and use composition as glue to form more complex functions.
961
961
However, many times, writing a function in point free style can be less readable if a function is too complex.
962
962
That's why making long chains of function composition is discouraged, although I plead guilty of sometimes being too composition-happy.
963
-
The preferred style is to use *let* bindings to give labels to intermediary results or split the problem into sub-problems and then put it together so that the function makes sense to someone reading it instead of just making a huge composition chain.
963
+
The preferred style is to use `let` bindings to give labels to intermediary results or split the problem into sub-problems and then put it together so that the function makes sense to someone reading it instead of just making a huge composition chain.
964
964
965
965
In the section about maps and filters, we solved a problem of finding the sum of all odd squares that are smaller than 10,000.
966
966
Here's what the solution looks like when put into a function.
0 commit comments