git @ Cat's Eye Technologies stringie / 6a56fa2
Try to clean up this document. Chris Pressey 3 years ago
1 changed file(s) with 17 addition(s) and 46 deletion(s). Raw diff Collapse all Expand all
00 Underload
11 =========
22
3 (This document was converted from the public-domain HTML Underload
4 specification in The Esoteric File Archive.)
3 (This document was converted from the public-domain
4 [HTML Underload specification][] in [The Esoteric File Archive][].)
55
66 Basics
77 ------
88
99 Underload is a stack-based programming language that works along similar
1010 lines to Muriel. Although not technically speaking a functional
11 language, its evaluation operator ^ (which is the only form of flow
11 language, its evaluation operator `^` (which is the only form of flow
1212 control) makes programming in it functional in practice.
1313
1414 Reserved characters
2525 Commands
2626 --------
2727
28 - ~ Swap the top two elements of the stack.
29 - : Duplicate the top element of the stack.
30 - ! Discard the top element of the stack.
31 - * Concatenate the top element of the stack to the end of the second
28 - `~` Swap the top two elements of the stack.
29 - `:` Duplicate the top element of the stack.
30 - `!` Discard the top element of the stack.
31 - `*` Concatenate the top element of the stack to the end of the second
3232 element of the stack.
33 - ( Push everything between the ( and the matching ) on top of
33 - `(` Push everything between the `(` and the matching `)` on top of
3434 the stack.
35 - ) Closes a ( command.
36 - a Encloses the top element of the stack in a pair of parentheses.
37 - ^ When the ^ command is called, it includes the top element of the
38 stack into the program, immediately after the ^ command, ready to be
35 - `)` Closes a `(` command.
36 - `a` Encloses the top element of the stack in a pair of parentheses.
37 - `^` When the `^` command is called, it includes the top element of the
38 stack into the program, immediately after the `^` command, ready to be
3939 run next.
40 - S Output the top element of the stack, popping it.
40 - `S` Output the top element of the stack, popping it.
4141
4242 Exceptional circumstances
4343 -------------------------
4444
4545 Pretty much anything whose behaviour isn't specifically given here (for
46 instance, running * on an empty stack) is an error.
47
48 Unlambda to Underload
49 ---------------------
50
51 The s, k, and i characters in Unlambda can all be translated directly
52 into Underload. Also, the ` character can be translated, but it has to
53 be moved to a postfix rather than prefix position, and .x can be
54 translated for most values of _x_.
55
56 - s translates to ((:)~*(~)*a(~*(~^)*)):
57 sx`y`z` = xz`yz`` (postfix notation)
58 sx`y`   = (:x~y~^)
59 sx`     = ((:x~)~*(~^)*)
60 s       = ((:)~*(~)*a(~*(~^)*)*)
61 - k translates to (a(!)~*)
62 - i translates to ()
63 - ` translates to ~^
64 - .x translates to ((x)S)
65
66 These translations prove that Underload is Turing-complete, because it
67 can be compiled into from the Turing-complete `sk Unlambda.
46 instance, running `*` on an empty stack) is an error.
6847
6948 Example programs
7049 ----------------
7756
7857 (()(*))(~:^:S*a~^a~!~*~:(/)S^):^
7958
80 (An ski`. Unlambda version is
81 ```s``s``sii`ki`k.*``s``s`ks``s`k`s`ks``s``s`ks``s`k`s`k./``s`k`sikk`k``s`ksk,
82 which can also be loaded up in the interpreter below by clicking on it;
83 you can automatically convert it to Underload if you wish to run it.)
84
8559 ### Infinite loop
8660
8761 (:^):^
88
89 (This is exactly equivalent to the ski`. Unlambda program ```sii``sii;
90 if the Unlambda program is converted to Underload using the compiler
91 below and run for a while, it eventually ends up in the same state as
92 the previous Underload program (the only difference being ~~, which has
93 no effect, in the code derived from the Unlambda).
9462
9563 ### Quine
9664
9866
9967 (The null program is also a quine. This program is more stack-based than
10068 functional.)
69
70 [HTML Underload specification]: https://cdn.rawgit.com/graue/esofiles/7ca16941/underload/underload.html
71 [The Esoteric File Archive]: https://esolangs.org/wiki/The_Esoteric_File_Archive