-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a document with the explanations
- Loading branch information
1 parent
b503a47
commit 26edcbf
Showing
11 changed files
with
119 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
⍝ simple assignment | ||
N←3 | ||
|
||
⍝ special value: ⎕ is stdout | ||
⎕←'hello world' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,2 @@ | ||
⍝ compose + and × (dot-free style) | ||
2 1000(+.×)4 5 | ||
|
||
⍝ is basically: | ||
+/2 1000×4 5 | ||
|
||
⍝ or | ||
+/(2×4) (1000×5) | ||
⍝ Doesn't work in GNU APL :( | ||
(⍴∘⍴) 3 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
=== Table of contents | ||
|
||
<table> | ||
<thead> | ||
<tr> | ||
<td>Filename</td> | ||
<td>Symbol</td> | ||
<td>Monadic</td> | ||
<td>Dyadic</td> | ||
<td>Operator <i>(higher-order)</i></td> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td>flat-contains (epsilon)</td> | ||
<td>∊</td> | ||
<td>Enlist</td> | ||
<td>Membership</td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>assign (left arrow)</td> | ||
<td>←</td> | ||
<td></td> | ||
<td>←</td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>shaped (rho)</td> | ||
<td>⍴</td> | ||
<td>Shape-of</td> | ||
<td>Reshape</td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>resize (up arrow)</td> | ||
<td>↑</td> | ||
<td>Roll</td> | ||
<td>Deal</td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>rand (question mark)</td> | ||
<td>?</td> | ||
<td>Roll</td> | ||
<td>Deal</td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>function (alpha and omega are the arguments)</td> | ||
<td>{ <i>and</i> }</td> | ||
<td>⍵ <b>(monadic argument)</b></td> | ||
<td>⍺ <b>(dyadic argument)</b></td> | ||
<td>function</td> | ||
</tr> | ||
<tr> | ||
<td>compose [<b>Dyalog only???</b>] (jot - higher-order function)</td> | ||
<td>∘</td> | ||
<td></td> | ||
<td></td> | ||
<td>monadic compose (e.g.: ⍴∘⍴)</td> | ||
</tr> | ||
<tr> | ||
<td>inner-product (dot)</td> | ||
<td>.</td> | ||
<td></td> | ||
<td></td> | ||
<td>inner product (e.g.: +.×)(becomes outer product when composed with jot)</td> | ||
</tr> | ||
<tr> | ||
<td>outer-product (jot/dot - higher-order function)</td> | ||
<td>∘. (monadic argument: operator)</td> | ||
<td></td> | ||
<td></td> | ||
<td>outer product (e.g.: ∘.+)</td> | ||
</tr> | ||
</tbody> | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
⍝ monadic: enlist (flatten) | ||
∊0 ((1 2) (3 4) (5 6)) | ||
|
||
⍝ dyadic: contains | ||
⍝ [a] is contained in [b] | ||
1∊1 2 3 | ||
1 2 4∊1 2 3 | ||
|
||
⎕←'Matrix' | ||
⍝ deep contain | ||
(3 3⍴⍳9)∊⍳5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
⍝ compose + and × (dot-free style) | ||
2 1000(+.×)4 5 | ||
|
||
⍝ is basically: | ||
+/2 1000×4 5 | ||
|
||
⍝ or | ||
+/(2×4) (1000×5) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
⍝ rand(1..3), rand(1..4), rand(1..5) | ||
⍝ monadic: roll | ||
?3 4 5 | ||
|
||
⍝ just generate dices 25x 1d20 | ||
?25⍴20 | ||
|
||
⍝ how many critical hits? sum of the dies that rolled 20 | ||
?25⍴20 | ||
|
||
⍝ dyadic: deal | ||
⍝ picks ⍺x 1d⍵ | ||
3?1000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
⍝ monadic: first | ||
↑ (6 4) 5 0 3 | ||
|
||
⍝ dyadic: take (zero-pads if ⍺>⍴⍵) | ||
30↑⍳10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
⍝ reshape | ||
⎕←5 6⍴ ⍳30 ⍝ outer size=5, inner size=6 | ||
⍝ range (iota)=30 | ||
|
||
⍝ shape of | ||
⍴5 6⍴ ⍳30 ⍝ easy enough, (5 6) | ||
|