Some edits to some notebooks.
This commit is contained in:
parent
356f67dd7d
commit
32d772e8b0
File diff suppressed because one or more lines are too long
|
|
@ -68,6 +68,12 @@ joy? zip
|
|||
|
||||
[[1 2] [0 7] [0 1] [1 19] [1 18] [1 3]]
|
||||
</code></pre>
|
||||
<h1>UGH! Pairs are in reverse order! Python vs. our Nice New Definition!</h1>
|
||||
<pre><code>[[2 1] [7 0] [1 0] [19 1] [18 1] [3 1]]
|
||||
</code></pre>
|
||||
<p>See <a href="/notebooks/DeriveZip.html">DeriveZip notebook</a>. Not that it matters
|
||||
for this application because we are about to multiply these pairs and,
|
||||
of course, multiplication is <a href="https://en.wikipedia.org/wiki/Commutative">commutative</a>.</p>
|
||||
<p>Now, for each pair we want to multiply the pairs (using the duality of Booleans as integers to convert the numbers we want to work on to themselves and the numbers we do not want to work on to zero which is the --I don't recall the jargon!-- zero times anything is zero, and zero plus anything is that thing, and we use that in a moment to get around actually filtering our list!) As I was saying we multiply the pairs, then square the result, then sum all the results:</p>
|
||||
<pre><code>[[1 2] [0 7] [0 1] [1 19] [1 18] [1 3]]
|
||||
|
||||
|
|
|
|||
|
|
@ -1981,18 +1981,6 @@ Like [getitem] but [swap]s the order of arguments.
|
|||
|
||||
[getitem]
|
||||
|
||||
|
||||
------------------------------------------------------------------------
|
||||
|
||||
## or
|
||||
|
||||
Logical bit-wise OR.
|
||||
|
||||
### Crosslinks
|
||||
|
||||
[and]
|
||||
|
||||
|
||||
------------------------------------------------------------------------
|
||||
|
||||
## over
|
||||
|
|
@ -3247,26 +3235,23 @@ Unquote (using [i]) the list that is second on the stack.
|
|||
|
||||
------------------------------------------------------------------------
|
||||
|
||||
## ||
|
||||
## or
|
||||
|
||||
Combinator
|
||||
|
||||
Short-circuiting Boolean OR
|
||||
|
||||
|
||||
### Discussion
|
||||
|
||||
Accept two quoted programs, run the first and expect a Boolean value, if
|
||||
it’s `false` pop it and run the second program (which should also return a
|
||||
Boolean value) otherwise pop the second program (leaving `true` on the
|
||||
stack.)
|
||||
stack.) The quoted programs are run with [nullary].
|
||||
|
||||
[A] [B] ||
|
||||
[A] [B] or
|
||||
---------------- A -> false
|
||||
B
|
||||
|
||||
|
||||
[A] [B] ||
|
||||
[A] [B] or
|
||||
---------------- A -> true
|
||||
true
|
||||
|
||||
|
|
|
|||
|
|
@ -69,6 +69,14 @@ Clunky, but we now have our list of filter integers. `zip` to transpose the two
|
|||
|
||||
[[1 2] [0 7] [0 1] [1 19] [1 18] [1 3]]
|
||||
|
||||
# UGH! Pairs are in reverse order! Python vs. our Nice New Definition!
|
||||
|
||||
[[2 1] [7 0] [1 0] [19 1] [18 1] [3 1]]
|
||||
|
||||
See [DeriveZip notebook](/notebooks/DeriveZip.html). Not that it matters
|
||||
for this application because we are about to multiply these pairs and,
|
||||
of course, multiplication is [commutative](https://en.wikipedia.org/wiki/Commutative).
|
||||
|
||||
Now, for each pair we want to multiply the pairs (using the duality of Booleans as integers to convert the numbers we want to work on to themselves and the numbers we do not want to work on to zero which is the --I don't recall the jargon!-- zero times anything is zero, and zero plus anything is that thing, and we use that in a moment to get around actually filtering our list!) As I was saying we multiply the pairs, then square the result, then sum all the results:
|
||||
|
||||
[[1 2] [0 7] [0 1] [1 19] [1 18] [1 3]]
|
||||
|
|
|
|||
Loading…
Reference in New Issue