More information at: https://wiki.helsinki.fi/display/lambda/esoteeriset+ohjelmointikielet
The presentation in the evening school: http://members.sange.fi/~atehwa/slides/esoteric.html
Underload is a minimalistic, stack-based language with first-class functions but without named functions or any kind of iteration constructs. An underload program is a series of commands that make modifications to an internal stack of values. The commands are represented by specific characters (for instance, "!" is a command to drop the top value of the internal stack), so a program is a string of command characters. The values on the stack are strings, too, and a value can be a program if it only contains command characters. There is a command ("^") to execute the top value on the stack as part of your program; this is the only flow control construct in the language.
The specific commands are documented here: http://esoteric.voxelperfect.net/files/underload/underload.html
Here is a simple program that outputs "Hello, nice nice world":
(world)(Hello, )(nice ):**~*S
Explanation: (world) pushes the string "world" on the stack, similarly for (Hello, ) and (nice ). After these commands, the Stack contains the following values (top of stack, or TOS, on the right):
(world), (Hello, ), (nice )
The ":" command duplicates the TOS, so that the stack becomes:
(world), (Hello, ), (nice ), (nice )
The "*" command concatenates the TOS and STOS (second-to-top of stack), so the stack turns into these with two "*" commands:
(world), (Hello, ), (nice nice ) (world), (Hello, nice nice )
The "~" command swaps TOS with STOS, so "~*" mutates the stack into:
(Hello, nice nice ), (world) (Hello, nice nice world)
The "S" command pops and outputs the TOS, printing "Hello, nice nice world".
This is a complete table of program states, with stack states on the left and program remaining to be executed on the right:
Stack Program (world)(Hello, )(nice ):**~*S (world) (Hello, )(nice ):**~*S (world), (Hello, ) (nice ):**~*S (world), (Hello, ), (nice ) :**~*S (world), (Hello, ), (nice ), (nice ) **~*S (world), (Hello, ), (nice nice ) *~*S (world), (Hello, nice nice ) ~*S (Hello, nice nice ), (world) *S (Hello, nice nice world) S
As another example, here is an explanation of how the infinite loop works:
(:^):^
After "(:^)", the TOS is the program ":^". Then when ":" is executed, the TOS is duplicated and stack contains the following values:
(:^), (:^)
Now the final command "^" takes one of these and executes it as a program. Now the program to be executed is ":^" and the stack contains:
(:^)
The ":" command duplicates, again, the TOS, so that the stack contains:
(:^), (:^)
After this, the "^" command will again pop and execute one of these, and the process repeats.
This is a complete table of program states for the infinite loop program:
Stack Program (:^):^Wont-reach-this (:^) :^Wont-reach-this (:^), (:^) ^Wont-reach-this (:^) :^Wont-reach-this (:^), (:^) ^Wont-reach-this ...
As before, you can send your solutions to the lecturer (atehwa at iki fi) if you want feedback, fame, or a comparison of your solution with others'.
Circute is a very simple cellular automaton. In Circute, "sparks" (#) spread in "wires" (=), and there are also "gates" (N), which send out sparks (to wires over and under them), except when they're surrounded by sparks from both sides (right and left), in which case they send out "spark erasers" (-). Essentially the automaton consists of the following rewrite rules (along with the symmetric and rotated rules):
#= -> ## e.g. ####==== -> #####=== -# -> =- e.g. ===-#### -> ====-### =N= -> =N= #N# -> #N# = # # - #N= -> #N= =N# -> =N# = # = #
The exact rewrite rules can be checked in Circute's Alpaca definition: http://catseye.tc/projects/circute/src/circute.alp
For example, here we have a NOT gate. The inputs are marked with stars (*), that is to say, you have to replace the stars with sparks or wires according to whether the boolean value of the input is true (spark) or false (wire). The result will be on the lowest line when no rewrite rule can no longer be applied to the automaton.
* === = = =N= =
You can send your solutions to the lecturer (atehwa at iki fi) if you want feedback, fame, or a comparison of your solution with others'.
Kysyttyjä / tiedottavia:
Pikalinkit: