Arcyóu
A Lisp for code golf. The parentheses cost bytes, so nearly every function is one or two characters long.
Benjamin Kulas, 2015 · Turing complete: yes · ●●○ moderate
Tested with 9 known programs · Hello World on Try It Online: identical except the line end · Test method
Run it
The idea
Benjamin Kulas wrote Arcyóu in Python in 2015, as a golfing language with Lisp syntax. The README gives two reasons. Lisp is easy to parse, and a library with a short name for almost everything pays for the extra parentheses. Missing closing parentheses at the end of a program are added for you, so a golfed program rarely ends in ))).
Read the story
Two rules make it odd. A name that is not defined is not an error; it evaluates to its own name as a string, so the program Q prints Q and is a one-character quine. And calling a string or a list indexes it, so ("abcdef" 1 3) is the slice bc.
The machine
Every top-level form is evaluated and only the last value is printed, with Python's str(). Values are Python's big integers, floats, booleans, strings, lists and None.
| Form | Does |
|---|---|
(+ a b ...) (- a b) (* a b) (/ a b) | Arithmetic; / is true division, #/ floor division |
(_ n) (_ a b) | range; a list or string alone gives its length |
(p x ...) | Print, and give the empty string |
(? c a b) | If c then a else b |
(f x list body) | The body for each x, collected into a list |
(@ cond body) | The body while cond holds, collected |
(F (x y) body) | A function; inside it $ is the function itself |
(: name value) | Set a global name |
(% f list) (/ f list) (r f list) | Map, filter, reduce |
p? d/ f! | Prime test, divisors, factorial, from math.arc |
A function binds its parameters as global names and deletes them when it returns, and a loop does the same with its variable. So calling (f! 4) deletes a global x you set before.
Example
The only form is a string, so it is the value that gets printed.
The only form is a string, so it is the value that gets printed.
The loop collects i * i for i in 1, 2 and 3, and Python prints the list.
The closing parenthesis is added at the end.
This implementation is a subset. It stops with a reason on the few library functions that read raw bytes, use the clock or randomness, on Python's % string formatting, and where the reference would print one of its own error messages.
Patterns it teaches
- Code golf: a huge library of short names against the cost of parentheses.
- Code as data: programs are lists, and an unknown name is just its own text.
- Quine: one undefined character prints itself.
Try this
- Print the squares of 1 to 10.
- Print the primes below 50 with
p?and a filter. - Hard: write a recursive Fibonacci function with
Fand$.
Further
- The reference interpreter, in Python
See also
Also in Golfing
Write your own in Run Convert a program from Arcyóu
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: arcyou.
Command line
shib run arcyou -e 'Q'shib manual arcyouSource
- Module
langs/tio/ports.js- Interpreter
langs/tio/arcyou.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language