AsciiFunc
Every statement is one punctuation mark and a pair of parentheses, and loops jump by number.
Ucrash and DexterHill0, 2021 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 3 known programs · Test method
Run it
The idea
Ucrash and DexterHill0 made AsciiFunc in 2021. A program is a row of commands such as $(n, num) or <(n), each one character with its arguments in parentheses. Commands are numbered from 0, and apart from function calls the only control flow is a jump to a number, either absolute or relative. Text between commands is comment, so a program can explain itself in plain words.
Read the story
Variables are typed as numbers, strings or booleans. A command whose types do not fit does nothing at all, with no error. There are functions with their own scopes, and imports of other files.
The machine
| Command | Does |
|---|---|
$(name, type) | Declare a num, str or bool |
= + | Set or add to a number |
: & | Set or append to a string |
! . | Negate a number, upper case or lower case a string, flip a bool |
@(v, a, b) | Clamp a number or slice a string |
%(a, b, v) | Compare a and b into v as 0, 1 or -1 |
" 1 | Convert to a string or a number |
<(v) >(type, v) | Print a line or read one |
#(i) ?(v, i, j) | Jump, or jump if v is true |
/ \ | | Declare, return from and call a function |
~(path) | Import a file; not here |
Example
A countdown.
A countdown. ?(n, 2) jumps back to command 2, the print, while n is not 0.
A function that doubles a string. The last argument of the call names the variable for the result.
A 99 bottles of beer program appends the number to the lyric with & and jumps back to command 3 until the bottles reach 0. It prints all 99 verses.
Further
See also
Also in Hostile
Write your own in Run Convert a program from AsciiFunc
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: asciifunc.
Command line
shib run asciifunc -e '$(s, str)
:(s, "Hello, World!")
<(s)'shib manual asciifuncSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/asciifunc.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org