User:Albedo: Difference between revisions
Content added Content deleted
(→Integer Sequence: Ackermann Function added) |
(Layout and order changed) |
||
Line 2: | Line 2: | ||
{{mylang|Piet|Intermediate}} |
{{mylang|Piet|Intermediate}} |
||
{{mylang|Julia|Beginner}} |
{{mylang|Julia|Beginner}} |
||
{{mylang|Cardinal|Intermediate}} |
|||
{{mylangend}} |
{{mylangend}} |
||
There aren’t any ways to upload images at the moment, so |
There aren’t any ways to upload images at the moment, so all examples are rendered as wikitables. See my PNG to wikitable conversion code written in Julia at the bottom of the page. |
||
==Explanation of shorthand code for Piet examples== |
|||
To shrink down the size of larger problems, I invented a shorthand text version for explaining the general program flow in a more compact form: |
To shrink down the size of larger problems, I invented a shorthand text version for explaining the general program flow in a more compact form: |
||
NOP ADD DIV GRT DUP INC END |
|||
. + / > = c ~ |
. + / > = c ~ |
||
PSH SUB MOD PTR ROL OUN |
|||
X - % # @ N |
X - % # @ N |
||
POP MUL NOT SWI INN OUC |
|||
? * ! $ n C |
? * ! $ n C |
||
Rendered as wikitable: |
|||
==Ackermann Function== |
==Ackermann Function== |
||
Line 384: | Line 389: | ||
==Integer Sequence== |
|||
[[Integer_sequence#Piet]] |
|||
PNG image download: |
|||
[Image:https://copy.com/TQuwy3dwBRl7nEOL] |
|||
Rendered as wikitable: |
|||
{| style="border-collapse: collapse; border-spacing: 0; font-family: courier-new,courier,monospace; font-size: 20px; line-height: 1.2em; padding: 0px" |
|||
| style="background-color:#ffc0c0; color:#ffc0c0;" | ww |
|||
| style="background-color:#ff0000; color:#ff0000;" | ww |
|||
| style="background-color:#c0ffc0; color:#c0ffc0;" | ww |
|||
| style="background-color:#ffc0c0; color:#ffc0c0;" | ww |
|||
| style="background-color:#ff00ff; color:#ff00ff;" | ww |
|||
| style="background-color:#ff00ff; color:#ff00ff;" | ww |
|||
| style="background-color:#c000c0; color:#c000c0;" | ww |
|||
|- |
|||
| style="background-color:#000000; color:#000000;" | ww |
|||
| style="background-color:#000000; color:#000000;" | ww |
|||
| style="background-color:#0000ff; color:#0000ff;" | ww |
|||
| style="background-color:#ff00ff; color:#ff00ff;" | ww |
|||
| style="background-color:#ff00ff; color:#ff00ff;" | ww |
|||
| style="background-color:#ff00ff; color:#ff00ff;" | ww |
|||
| style="background-color:#00c0c0; color:#00c0c0;" | ww |
|||
|- |
|||
| style="background-color:#000000; color:#000000;" | ww |
|||
| style="background-color:#000000; color:#000000;" | ww |
|||
| style="background-color:#0000ff; color:#0000ff;" | ww |
|||
| style="background-color:#0000ff; color:#0000ff;" | ww |
|||
| style="background-color:#00c0c0; color:#00c0c0;" | ww |
|||
| style="background-color:#00ffff; color:#00ffff;" | ww |
|||
| style="background-color:#0000ff; color:#0000ff;" | ww |
|||
|} |
|||
(7x3 codels) |
|||
Opcodes: |
|||
1 PSH NOT DUP OUN 5 PSH |
|||
ROL |
|||
ADD DUP |
|||
PSH 1 OUC ADD |
|||
Shorthand: |
|||
1 X ! = N 5 X |
|||
@ . |
|||
+ = |
|||
X 1 C + |
|||
0 \n 1 \n 2 \n 3 OUTPUT |
|||
————————————————————————————————————————————————————————————————————————————— |
|||
5 5 5 |
|||
0 5 5 10 1 1 5 5 10 1 2 5 5 10 1 3 STACK |
|||
1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 3 3 3 3 ... |
|||
————————————————————————————————————————————————————————————————————————————— |
|||
1X ! = N 5X = + C 1X + @ = N 5X = + C 1X + @ = N 5X = + C 1X + @ = N ... |
|||
| \_____/ | | | |
|||
| | | | +—————————— Repeating the Loop |
|||
| | | | |
|||
| | | +———————————— ROL acting as NOP (stack too small), needed to guide the codel chooser |
|||
| | | |
|||
| | +—————————————— Count up |
|||
| | |
|||
| +———————————————————————— 10 = ASCII for \n (newline) |
|||
| |
|||
+————————————————————————————————— !1=0 (Sequence begins at 0) |
|||
==Binary Digits== |
==Binary Digits== |
||
Line 676: | Line 603: | ||
↑ . . |
↑ . . |
||
l4 .... |
l4 .... |
||
==Integer Sequence== |
|||
[[Integer_sequence#Piet]] |
|||
PNG image download: |
|||
[Image:https://copy.com/TQuwy3dwBRl7nEOL] |
|||
Rendered as wikitable: |
|||
{| style="border-collapse: collapse; border-spacing: 0; font-family: courier-new,courier,monospace; font-size: 20px; line-height: 1.2em; padding: 0px" |
|||
| style="background-color:#ffc0c0; color:#ffc0c0;" | ww |
|||
| style="background-color:#ff0000; color:#ff0000;" | ww |
|||
| style="background-color:#c0ffc0; color:#c0ffc0;" | ww |
|||
| style="background-color:#ffc0c0; color:#ffc0c0;" | ww |
|||
| style="background-color:#ff00ff; color:#ff00ff;" | ww |
|||
| style="background-color:#ff00ff; color:#ff00ff;" | ww |
|||
| style="background-color:#c000c0; color:#c000c0;" | ww |
|||
|- |
|||
| style="background-color:#000000; color:#000000;" | ww |
|||
| style="background-color:#000000; color:#000000;" | ww |
|||
| style="background-color:#0000ff; color:#0000ff;" | ww |
|||
| style="background-color:#ff00ff; color:#ff00ff;" | ww |
|||
| style="background-color:#ff00ff; color:#ff00ff;" | ww |
|||
| style="background-color:#ff00ff; color:#ff00ff;" | ww |
|||
| style="background-color:#00c0c0; color:#00c0c0;" | ww |
|||
|- |
|||
| style="background-color:#000000; color:#000000;" | ww |
|||
| style="background-color:#000000; color:#000000;" | ww |
|||
| style="background-color:#0000ff; color:#0000ff;" | ww |
|||
| style="background-color:#0000ff; color:#0000ff;" | ww |
|||
| style="background-color:#00c0c0; color:#00c0c0;" | ww |
|||
| style="background-color:#00ffff; color:#00ffff;" | ww |
|||
| style="background-color:#0000ff; color:#0000ff;" | ww |
|||
|} |
|||
(7x3 codels) |
|||
Opcodes: |
|||
1 PSH NOT DUP OUN 5 PSH |
|||
ROL |
|||
ADD DUP |
|||
PSH 1 OUC ADD |
|||
Shorthand: |
|||
1 X ! = N 5 X |
|||
@ . |
|||
+ = |
|||
X 1 C + |
|||
0 \n 1 \n 2 \n 3 OUTPUT |
|||
————————————————————————————————————————————————————————————————————————————— |
|||
5 5 5 |
|||
0 5 5 10 1 1 5 5 10 1 2 5 5 10 1 3 STACK |
|||
1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 3 3 3 3 ... |
|||
————————————————————————————————————————————————————————————————————————————— |
|||
1X ! = N 5X = + C 1X + @ = N 5X = + C 1X + @ = N 5X = + C 1X + @ = N ... |
|||
| \_____/ | | | |
|||
| | | | +—————————— Repeating the Loop |
|||
| | | | |
|||
| | | +———————————— ROL acting as NOP (stack too small), needed to guide the codel chooser |
|||
| | | |
|||
| | +—————————————— Count up |
|||
| | |
|||
| +———————————————————————— 10 = ASCII for \n (newline) |
|||
| |
|||
+————————————————————————————————— !1=0 (Sequence begins at 0) |
|||