Skip to content

Commit c170c35

Browse files
chad3814smith558
andauthored
fix a couple of typos (#71)
* fix typo Signed-off-by: chad3814 <chad@cwalker.dev> * be consistent with `square` and `square root` * fix extra "right" typo, turning it into a playful question --------- Signed-off-by: chad3814 <chad@cwalker.dev> Co-authored-by: Stanislav (Stanley) Modrak <44023416+smith558@users.noreply.github.com>
1 parent 75ebe3f commit c170c35

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

docs/higher-order-functions.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ <h1 style="margin-left:-3px">Higher order functions</h1>
376376
[[],[3],[2,3],[1,2,3]]
377377
</pre>
378378
<p>When using a <span class="fixed">scanl</span>, the final result will be in the last element of the resulting list while a <span class="fixed">scanr</span> will place the result in the head.</p>
379-
<p>Scans are used to monitor the progression of a function that can be implemented as a fold. Let's answer us this question: <em>How many elements does it take for the sum of the roots of all natural numbers to exceed 1000?</em> To get the squares of all natural numbers, we just do <span class="fixed">map sqrt [1..]</span>. 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. Once we've done the scan, we just see how many sums are under 1000. The first sum in the scanlist will be 1, normally. The second will be 1 plus the square root of 2. The third will be that plus the square root of 3. If there are X sums under 1000, then it takes X+1 elements for the sum to exceed 1000.</p>
379+
<p>Scans are used to monitor the progression of a function that can be implemented as a fold. Let's answer us this question: <em>How many elements does it take for the sum of the square roots of all natural numbers to exceed 1000?</em> To get the square roots of all natural numbers, we just do <span class="fixed">map sqrt [1..]</span>. 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. Once we've done the scan, we just see how many sums are under 1000. The first sum in the scanlist will be 1, normally. The second will be 1 plus the square root of 2. The third will be that plus the square root of 3. If there are X sums under 1000, then it takes X+1 elements for the sum to exceed 1000.</p>
380380
<pre name="code" class="haskell:hs">
381381
sqrtSums :: Int
382382
sqrtSums = length (takeWhile (&lt;1000) (scanl1 (+) (map sqrt [1..]))) + 1
@@ -440,7 +440,7 @@ <h1 style="margin-left:-3px">Higher order functions</h1>
440440
sum' :: (Num a) =&gt; [a] -&gt; a
441441
sum' xs = foldl (+) 0 xs
442442
</pre>
443-
<p>The <span class="fixed">xs</span> is exposed on both right sides. Because of currying, we can omit the <span class="fixed">xs</span> on both sides, because calling <span class="fixed">foldl (+) 0</span> creates a function that takes a list. Writing the function as <span class="fixed">sum' = foldl (+) 0</span> is called writing it in point free style. How would we write this in point free style?</p>
443+
<p>The <span class="fixed">xs</span> is exposed on both sides, right? Because of currying, we can omit the <span class="fixed">xs</span> on both sides, because calling <span class="fixed">foldl (+) 0</span> creates a function that takes a list. Writing the function as <span class="fixed">sum' = foldl (+) 0</span> is called writing it in point free style. How would we write this in point free style?</p>
444444
<pre name="code" class="haskell:hs">
445445
fn x = ceiling (negate (tan (cos (max 50 x))))
446446
</pre>

docs/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ <h1 style="display: none;">A guide to Haskell programming language</h1>
8484
</p>
8585
</div>
8686
<p>
87-
Anyone is invited to <em style="color: greenyellow">contribute</em> be either <a class="nostarchlink" href="https://github.com/learnyouahaskell/learnyouahaskell.github.io">opening a pull request</a>
87+
Anyone is invited to <em style="color: greenyellow">contribute</em> by either <a class="nostarchlink" href="https://github.com/learnyouahaskell/learnyouahaskell.github.io">opening a pull request</a>
8888
(preferred) or opening a <a class="nostarchlink" href="https://github.com/learnyouahaskell/learnyouahaskell.github.io/issues/new/choose">content edit request</a> for proposed changes.
8989
</p>
9090
<p>

0 commit comments

Comments
 (0)