Suzy
Jump to navigation
Jump to search
Suzy is a 3D esoteric programming language, inspired by Befunge, superseding 3D. Suzy source is compiled to byte-code in the original implementation. Comments are made by directing code flow around them. It includes file I/O as well as STDIN/STDOUT. Every non-control ASCII character is used as an operation or variable name.
Commands
No-op: (space) do nothing | vertical pipe (do nothing) - horizontal pipe (if not in math mode) ' lateral pipe Execution control: @ end Flow control: { right } left ^ up _ down [ forwards ] backwards % random direction # jump $ conditional jump Conditional jump preparation: = equality < smaller than > greater than Input/output: ? input ! output File access: / open a file for input and output Libraries: + load a library Variable handling: : set a variable to a value ( enter math mode ) leave math mode " enter/leave unicode mode . cat strings , substring ~ swap two variables String mode: ` temporary escape unicode mode, for changing directions \ escape sequence Math mode: + addition - subtraction * multiplication / division % modulus division Numeric: 0-9 numeric constants Variable names: A-Z string variable names a-z integer variable names \ indirect variable mode (if not in ascii/unicode mode) Arguments: ; separates 2 arguments Unused: & unused in Suzy proper (except in strings, of course), but can be used in a Suzy source file to separate sheets
Example
The following lists all primes up to a given bound:
32,7,3 }!"Primes up to: "?A ~Aa ] a is the maxprime p is the index of the stack stack is the list of primes n is the number that is checked for primeness i is a temp stack index & ] 3n:1p: "2"! _$0001a> 2;0\:{ }!"Too large!\n"@ & } >na$@ --- :i0 } =(n/\i*\i)n _ | ^---------{ $ | }:i(i+1)^ # | _p:p\!np\:" ,"!^$)n/(i\< { | }(p+1) _ | ^--)1+n(n: {------------------{
Computational class
The author thinks Suzy is Turing Complete, because it is possible to translate any BrainFuck program to Suzy:
> becomes :p(p+) < becomes :p(p-) + becomes :\p(\p+) - becomes :\p(\p-) [ becomes }=\p0$_ (with a pipe from _ to the corresponding }) ] becomes _} (with a pipe from _ to the corresponding })
Input and output work differently, but could be translated as:
, becomes ?\p . becomes !\p
However, I/O is not necessary for Turing Completeness, so that doesn't matter.
Implementation
A full featured implementation in Python of both byte-code compiler and interpreter are on GitHub.