Skip to content

Commit 5b3a7da

Browse files
committed
various
1 parent 513323b commit 5b3a7da

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

source_md/higher-order-functions.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -796,14 +796,14 @@ ghci> scanl (flip (:)) [] [3,2,1]
796796
When using a `scanl`, the final result will be in the last element of the resulting list while a `scanr` will place the result in the head.
797797

798798
Scans are used to monitor the progression of a function that can be implemented as a fold.
799-
Let's answer us this question: **How many elements does it take for the sum of the square roots of all natural numbers to exceed 1000?**
799+
Let's answer us this question: **How many elements does it take for the sum of the square roots of all natural numbers to exceed $1000$?**
800800
To get the square roots of all natural numbers, we just do `map sqrt [1..]`.
801801
Now, to get the sum, we could do a fold, but because we're interested in how the sum progresses, we're going to do a scan.
802-
Once we've done the scan, we just see how many sums are under 1000.
803-
The first sum in the scanlist will be 1, normally.
804-
The second will be 1 plus the square root of 2.
805-
The third will be that plus the square root of 3.
806-
If there are X sums under 1000, then it takes X+1 elements for the sum to exceed 1000.
802+
Once we've done the scan, we just see how many sums are under $1000$.
803+
The first sum in the scanlist will be $1$, normally.
804+
The second will be $1 + \sqrt 2$.
805+
The third will be $1 + \sqrt 2 + \sqrt 3$.
806+
If there are $n$ sums under 1000, then it takes $n + 1$ elements for the sum to exceed $1000$.
807807

808808
```{.haskell:hs}
809809
sqrtSums :: Int
@@ -820,7 +820,7 @@ ghci> sum (map sqrt [1..130])
820820
```
821821

822822
We use `takeWhile` here instead of `filter` because `filter` doesn't work on infinite lists.
823-
Even though we know the list is ascending, `filter` doesn't, so we use `takeWhile` to cut the scanlist off at the first occurrence of a sum greater than 1000.
823+
Even though we know the list is ascending, `filter` doesn't, so we use `takeWhile` to cut the scanlist off at the first occurrence of a sum greater than $1000$.
824824

825825
## Function application with $ {#function-application}
826826

source_md/starting-out.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ ghci> triangles = [ (a,b,c) | c <- [1..10], a <- [1..10], b <- [1..10] ]
884884
We're just drawing from three lists and our output function is combining them into a triple.
885885
If you evaluate that by typing out `triangles` in GHCi, you'll get a list of all possible triangles with sides under or equal to 10.
886886
Next, we'll add a condition that they all have to be right triangles.
887-
We'll also modify this function by taking into consideration that side *a* isn't larger than the hypotenuse and that side *b* isn't larger than side *a*.
887+
We'll also modify this function by taking into consideration that side $a$ isn't larger than the hypotenuse and that side $b$ isn't larger than side $a$.
888888

889889
```{.haskell: .ghci}
890890
ghci> rightTriangles = [ (a,b,c) | c <- [1..10], a <- [1..c], b <- [1..a], a^2 + b^2 == c^2]

source_md/syntax-in-functions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ When making patterns, we should always include a catch-all pattern so that our p
9191

9292
Pattern matching can also be used on tuples.
9393
What if we wanted to make a function that takes two vectors in a 2D space (that are in the form of pairs) and adds them together?
94-
To add together two vectors, we add their x components separately and then their y components separately.
94+
To add together two vectors, we add their $x$ components separately and then their $y$ components separately.
9595
Here's how we would have done it if we didn't know about pattern matching:
9696

9797
```{.haskell:hs}

0 commit comments

Comments
 (0)