Page namespace (page_namespace) | 0 |
Page title (without namespace) (page_title) | 'Pyramid Scheme' |
Full page title (page_prefixedtitle) | 'Pyramid Scheme' |
Old content model (old_content_model) | '' |
New content model (new_content_model) | 'wikitext' |
Old page wikitext, before the edit (old_wikitext) | '' |
New page wikitext, after the edit (new_wikitext) | '{{DISPLAYTITLE:Pyramid Scheme}}
{{infobox proglang
|name=Pyramid Scheme
|paradigms=declarative
|author=Conor O'Brien
|year=[[:Category:2017|2017]]
|class=[[:Category:Turing complete|Turing complete]]
|refimpl=[https://github.com/ConorOBrien-Foxx/Pyramid-Scheme]
|influence=[[Lisp]]
|files=<code>.pyr</code>, <code>.pyra</code>
}}
Pyramid Scheme is an [[esoteric programming language]] created by [https://github.com/ConorOBrien-Foxx Conor O'Brien] in early 2017. It is a dialect of [[Lisp]], but it uses ascii-art pyramid structures as opposed to brackets.
== Entymology ==
The name is a joke on the name of a different Lisp dialect called [https://en.wikipedia.org/wiki/Scheme_(programming_language) Scheme], and its similarity to a (widely frowned-upon and illegal) business model called the [https://en.wikipedia.org/wiki/Pyramid_scheme pyramid scheme].
== Sample programs ==
=== If/Else statement ===
The following is an implementation of an if-else statement in pyramid scheme. It prints if A is 1 for truthy, and 0 if it is falsey
^ ^
/ \ / \
/set\ / \
^-----^ / ? \
/A\ /1\ ^-------^
--- --- /!\ / \
^--- /out\
/ \ ^-----
/ ? \ /0\
^-----^ ---
/A\ / \
--- /out\
^-----
/1\
---
This is equivalent to the lisp-like syntax:
(set A 1)
(? (! (? A (out 1))) (out 0))
=== Modulo function ===
Pyramid scheme does not have an implementation of the modulo function. A modulo of a number has to, therefore, be calculated with repeated subtraction. The following implements the ''mod(a,b)'' function:
^ ^ ^ ^
/ \ / \ / \ / \
/set\ /set\ / \ /out\
^-----^ ^-----^ / \ -----^
/a\ / \ /b\ / \ / \ /a\
--- /33 \--- /16 \ / loop \ ---
----- ----- ^-----------^
/ \ / \
/ \ /set\
/ <=> \ ^-----^
^-------^ /a\ /-\
/ \ / \ --- ^---^
/<=>\ /-1 \ /a\ /b\
^-----^ ----- --- ---
/a\ /b\
--- ---
which is equivalent to lisp-like:
(set a 33)
(set b 16)
(loop (<=> (<=> a b) -1) (set a (- a b)))
(out a)
== External resources ==
* [https://github.com/ConorOBrien-Foxx/Pyramid-Scheme Pyramid Scheme] on GitHub
* [https://tio.run/##rZFBCoQwDEX3PcW/gLTRgh5GBFHBWYiDowtPX22chZVuismir/lJCj/97ks7ffrs143DNDgHNOAIENNSoKBR@1uAmJYGpedtPZMAMS0VKvPRIACfeAcFEeOPNXh041KL4nxVxPJzAeLudZn7RJOhCxWDOLOWa8XVUpW41YjsfcAY7izw/35AEM4d Hello world in Pyramid Scheme] on TIO' |
Lines added in edit (added_lines) | [
0 => '{{DISPLAYTITLE:Pyramid Scheme}}',
1 => '{{infobox proglang',
2 => '|name=Pyramid Scheme',
3 => '|paradigms=declarative',
4 => '|author=Conor O'Brien',
5 => '|year=[[:Category:2017|2017]]',
6 => '|class=[[:Category:Turing complete|Turing complete]]',
7 => '|refimpl=[https://github.com/ConorOBrien-Foxx/Pyramid-Scheme]',
8 => '|influence=[[Lisp]]',
9 => '|files=<code>.pyr</code>, <code>.pyra</code>',
10 => '}}',
11 => '',
12 => 'Pyramid Scheme is an [[esoteric programming language]] created by [https://github.com/ConorOBrien-Foxx Conor O'Brien] in early 2017. It is a dialect of [[Lisp]], but it uses ascii-art pyramid structures as opposed to brackets.',
13 => '',
14 => '== Entymology ==',
15 => '',
16 => 'The name is a joke on the name of a different Lisp dialect called [https://en.wikipedia.org/wiki/Scheme_(programming_language) Scheme], and its similarity to a (widely frowned-upon and illegal) business model called the [https://en.wikipedia.org/wiki/Pyramid_scheme pyramid scheme].',
17 => '',
18 => '== Sample programs ==',
19 => '',
20 => '=== If/Else statement ===',
21 => '',
22 => 'The following is an implementation of an if-else statement in pyramid scheme. It prints if A is 1 for truthy, and 0 if it is falsey',
23 => '',
24 => ' ^ ^',
25 => ' / \ / \',
26 => ' /set\ / \',
27 => ' ^-----^ / ? \',
28 => ' /A\ /1\ ^-------^',
29 => ' --- --- /!\ / \',
30 => ' ^--- /out\',
31 => ' / \ ^-----',
32 => ' / ? \ /0\',
33 => ' ^-----^ ---',
34 => ' /A\ / \',
35 => ' --- /out\',
36 => ' ^-----',
37 => ' /1\',
38 => ' ---',
39 => '',
40 => 'This is equivalent to the lisp-like syntax:',
41 => '',
42 => ' (set A 1)',
43 => ' (? (! (? A (out 1))) (out 0))',
44 => '',
45 => '=== Modulo function ===',
46 => '',
47 => 'Pyramid scheme does not have an implementation of the modulo function. A modulo of a number has to, therefore, be calculated with repeated subtraction. The following implements the ''mod(a,b)'' function:',
48 => '',
49 => ' ^ ^ ^ ^',
50 => ' / \ / \ / \ / \',
51 => ' /set\ /set\ / \ /out\',
52 => ' ^-----^ ^-----^ / \ -----^',
53 => ' /a\ / \ /b\ / \ / \ /a\',
54 => ' --- /33 \--- /16 \ / loop \ ---',
55 => ' ----- ----- ^-----------^',
56 => ' / \ / \',
57 => ' / \ /set\',
58 => ' / <=> \ ^-----^',
59 => ' ^-------^ /a\ /-\',
60 => ' / \ / \ --- ^---^',
61 => ' /<=>\ /-1 \ /a\ /b\',
62 => ' ^-----^ ----- --- ---',
63 => ' /a\ /b\',
64 => ' --- ---',
65 => '',
66 => 'which is equivalent to lisp-like:',
67 => '',
68 => ' (set a 33)',
69 => ' (set b 16)',
70 => ' (loop (<=> (<=> a b) -1) (set a (- a b)))',
71 => ' (out a)',
72 => '',
73 => '== External resources ==',
74 => '',
75 => '* [https://github.com/ConorOBrien-Foxx/Pyramid-Scheme Pyramid Scheme] on GitHub',
76 => '* [https://tio.run/##rZFBCoQwDEX3PcW/gLTRgh5GBFHBWYiDowtPX22chZVuismir/lJCj/97ks7ffrs143DNDgHNOAIENNSoKBR@1uAmJYGpedtPZMAMS0VKvPRIACfeAcFEeOPNXh041KL4nxVxPJzAeLudZn7RJOhCxWDOLOWa8XVUpW41YjsfcAY7izw/35AEM4d Hello world in Pyramid Scheme] on TIO'
] |