Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ffbc54f

Browse files
Merge pull request #47 from justinmeiners/10-clarifications
10 clarifications
2 parents bbe934c + b9ae73d commit ffbc54f

File tree

7 files changed

+471
-351
lines changed

7 files changed

+471
-351
lines changed

‎05_swap.html

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ <h3>Relative and absolute efficiency</h3>
210210
I still program in C++ because as far as I could ascertain it&rsquo;s the only language which allows me
211211
generality and absolute efficiency.
212212
I can program as general as I like.
213-
I can talk about things like <a href="https://en.wikipedia.org/wiki/Monoid">monoids</a> and <a href="https://en.wikipedia.org/wiki/Semigroup">semi-groups</a>.
213+
I can talk about things like <a href="https://en.wikipedia.org/wiki/Monoid">monoids</a> and <a href="https://en.wikipedia.org/wiki/Semigroup">semi-groups</a><supid="fnref:1"><ahref="#fn:1" rel="footnote">1</a></sup>.
214214
When it compiles I could look at assembly code and see it is good.
215215
It is absolutely efficient.</p>
216216

@@ -275,7 +275,7 @@ <h2>Swap</h2>
275275
sequence, you swap.
276276
So it is very important practically.
277277
But it also happens to be very important
278-
theoretically, because a long time ago when people were starting group theory<supid="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup>
278+
theoretically, because a long time ago when people were starting <a href="https://en.wikipedia.org/wiki/Group_theory">group theory</a>
279279
they discovered that any permutation of a sequence could be generated out of swap<sup id="fnref:2"><a href="#fn:2" rel="footnote">2</a></sup>.
280280
Swap is the most primitive operation.
281281
The reason is sequence. And any other
@@ -482,15 +482,35 @@ <h2>Code</h2>
482482
<hr/>
483483
<ol>
484484
<li id="fn:1">
485-
<p><a href="https://en.wikipedia.org/wiki/Group_theory">Group theory</a>
486-
is one of the main subjects of abstract algebra.
487-
The key idea is that many mathematical structures behave similarly.
488-
You can add and subtract numbers, you can add and subtract vectors and matrices.
489-
Can we study all structures which can add and subtract all together?
490-
It turns out you can, and one such structure is a group.</p>
491-
492-
<p>Alex&rsquo;s ideas about generic programming are inspired
493-
by abstract algebra.</p><a href="#fnref:1" rev="footnote">&#8617;</a></li>
485+
<p>Groups, monoids, and rings are a few of the subjects of abstract algebra,
486+
a field which studies the fundamental properties of mathematical structures.
487+
The key idea is that many different mathematical objects appear to function similarly.
488+
Vectors and matrices can be &ldquo;added&rdquo; and &ldquo;subtracted&rdquo; just like integers.
489+
In what ways are they fundamentally the same?
490+
One explanation is that all of them form a group.
491+
Below is a formal definition:</p>
492+
493+
<p>A <strong>group</strong> is a set <code>G</code> with a binary operation <code>* : G x G -&gt; G</code> such that:</p>
494+
495+
<ol>
496+
<li><code>G</code> contains an identity element <code>e</code> in <code>G</code> such that <code>e * x = x * e = x</code> for all <code>x</code> in <code>G</code>.</li>
497+
<li>The operation <code>*</code> is associative. So <code>((x * y) * z) = (x * (y * z))</code> for all <code>x, y, z</code> in <code>G</code>.</li>
498+
<li>Every element <code>x</code> in <code>G</code> has an inverse element <code>y</code> such that x * y = y * x = e.</li>
499+
</ol>
500+
501+
502+
<p>For example integers are a group with the operation of addition and the identity element 0.</p>
503+
504+
<ol>
505+
<li><code>0 + x = x + 0 = x</code></li>
506+
<li><code>((x + y) + z) = (x + (y + z))</code>.</li>
507+
<li><code>x + (-x) = (-x) + x = 0</code>.</li>
508+
</ol>
509+
510+
511+
<p>The process of discovering and applying generic concepts is very similar.
512+
Alex introduces the basics of abstract algebra, from a programmers perspective,
513+
in his book &ldquo;From Mathematics to Generic Programming&rdquo;.</p><a href="#fnref:1" rev="footnote">&#8617;</a></li>
494514
<li id="fn:2">
495515
<p>A <a href="https://en.wikipedia.org/wiki/Permutation_group">permutation</a>
496516
is a bijection (1-1, onto) map from a set to itself.
@@ -537,8 +557,7 @@ <h2>Code</h2>
537557
<li id="fn:4">
538558
Alex himself uses Tropical semi-rings to describe
539559
several algorithms in his book &ldquo;From Mathematics to Generic Programming&rdquo; (See chapter 8.6).
540-
So his issue here is not algebraic abstractions, but pursuing abstraction
541-
with enormous cost.<a href="#fnref:4" rev="footnote">&#8617;</a></li>
560+
So his issue here is not abstraction itself, rather that it can become too costly.<a href="#fnref:4" rev="footnote">&#8617;</a></li>
542561
<li id="fn:5">
543562
<p>The <code>^</code> symbol is bitwise <a href="https://en.wikipedia.org/wiki/Exclusive_or">exclusive or</a>.
544563
The expression <code>a ^ b</code> means <code>a</code> is true, or <code>b</code> is true, but not both.

‎05_swap.md

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ After all, I didn't start with C++.
8080
I still program in C++ because as far as I could ascertain it's the only language which allows me
8181
generality and absolute efficiency.
8282
I can program as general as I like.
83-
I can talk about things like [monoids][monoid] and [semi-groups][semi-group].
83+
I can talk about things like [monoids][monoid] and [semi-groups][semi-group][^about-group-theory].
8484
When it compiles I could look at assembly code and see it is good.
8585
It is absolutely efficient.
8686

@@ -146,7 +146,7 @@ Basically if you do something with a
146146
sequence, you swap.
147147
So it is very important practically.
148148
But it also happens to be very important
149-
theoretically, because a long time ago when people were starting group theory[^group-theory]
149+
theoretically, because a long time ago when people were starting [group theory][group-theory]
150150
they discovered that any permutation of a sequence could be generated out of swap[^permutation].
151151
Swap is the most primitive operation.
152152
The reason is sequence. And any other
@@ -159,16 +159,31 @@ the greatest language was great, and since it couldn't do swap,
159159
what do you do?
160160
You deny the utility of swap.
161161

162-
[^group-theory]: [Group theory](https://en.wikipedia.org/wiki/Group_theory)
163-
is one of the main subjects of abstract algebra.
164-
The key idea is that many mathematical structures behave similarly.
165-
You can add and subtract numbers, you can add and subtract vectors and matrices.
166-
Can we study all structures which can add and subtract all together?
167-
It turns out you can, and one such structure is a group.
162+
[group-theory]: https://en.wikipedia.org/wiki/Group_theory
168163

169-
Alex's ideas about generic programming are inspired
170-
by abstract algebra.
164+
[^about-group-theory]: Groups, monoids, and rings are a few of the subjects of abstract algebra,
165+
a field which studies the fundamental properties of mathematical structures.
166+
The key idea is that many different mathematical objects appear to function similarly.
167+
Vectors and matrices can be "added" and "subtracted" just like integers.
168+
In what ways are they fundamentally the same?
169+
One explanation is that all of them form a group.
170+
Below is a formal definition:
171+
172+
A **group** is a set `G` with a binary operation `* : G x G -> G` such that:
173+
174+
1. `G` contains an identity element `e` in `G` such that `e * x = x * e = x` for all `x` in `G`.
175+
2. The operation `*` is associative. So `((x * y) * z) = (x * (y * z))` for all `x, y, z` in `G`.
176+
3. Every element `x` in `G` has an inverse element `y` such that x * y = y * x = e.
177+
178+
For example integers are a group with the operation of addition and the identity element 0.
179+
180+
1. `0 + x = x + 0 = x`
181+
2. `((x + y) + z) = (x + (y + z))`.
182+
3. `x + (-x) = (-x) + x = 0`.
171183

184+
The process of discovering and applying generic concepts is very similar.
185+
Alex introduces the basics of abstract algebra, from a programmers perspective,
186+
in his book "From Mathematics to Generic Programming".
172187

173188
[^permutation]: A [permutation](https://en.wikipedia.org/wiki/Permutation_group)
174189
is a bijection (1-1, onto) map from a set to itself.
@@ -261,8 +276,7 @@ and the `T` parameter is still generic.
261276

262277
[^tropical]: Alex himself uses Tropical semi-rings to describe
263278
several algorithms in his book "From Mathematics to Generic Programming" (See chapter 8.6).
264-
So his issue here is not algebraic abstractions, but pursuing abstraction
265-
with enormous cost.
279+
So his issue here is not abstraction itself, rather that it can become too costly.
266280

267281
[^move]:
268282
Since C++11 this issue has been addressed by [move semantics](https://en.cppreference.com/w/cpp/language/move_constructor)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /