esolang

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

Expected: a a

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

TextMeans
f x yf applied to x, then to y
f (g x)Parentheses group an argument
XA 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.

Expected: s (s (s (s (s (s (s (s 0)))))))

Rules are tried in order, so the specific one goes first. Swap these two and eq is always f.

Expected: t f

Patterns it teaches

Further

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 anemone

Source

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