Anemone
No lambda and no assignment. A program is a list of rules that say what a term reduces to.
Afarnen, 2010 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 7 known programs · Test method
Run it
The idea
Afarnen made Anemone in 2010 from combinatory logic and pattern matching. A term is an atom, or one term applied to another. A program computes nothing by itself. It is a list of rules, and the interpreter asks for terms and prints each one back once no rule fits any more.
Read the story
Names with a capital first letter are variables and stand for any term. A rule may use a variable twice, and then both places need the same term, which is how eq X X = t. tests equality. Three rules give the SKI calculus, so Anemone is Turing complete.
The machine
| Text | Means |
|---|---|
f x y | f applied to x, then to y |
f (g x) | Parentheses group an argument |
X | A variable, any name with a capital first letter |
left = right. | A rule, tried in the order of the program |
Each step rewrites the outermost term that a rule fits, with the first rule that fits it. The specification's test runs show what outermost means. A term and the shorter applications in its head come first, then its arguments from left to right, then their arguments, level by level. Every input line is one term, and its normal form is printed on a line of its own.
Example
The SKI calculus and a self application.
The SKI calculus and a self application.
Numbers are 0, s 0, s (s 0) and so on. The sixth Fibonacci number takes 32 reductions, and each of them matches the specification.
Rules are tried in order, so the specific one goes first. Swap these two and eq is always f.
Patterns it teaches
- String rewriting: rules tried in order until none fits, on trees instead of strings.
- Combinators: S, K and I take three rules.
Further
See also
Meta-languages
Functional paradigm
Write your own in Run Convert a program from Anemone
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: anemone.
Command line
shib run anemone -e 'eq X X = t.
eq X Y = f.' --input 'eq a a
eq a b
eq (cons a b) (cons a b)'shib manual anemoneSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/anemone.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org