esolang

Birb

Fifteen bird emojis, each one a combinator. A program is a flock, and it walks with a stagger.

Melvin and SCKelemen, 2021 · Turing complete: yes · ●●● hard · esolangs.org

Tested with 11 known programs · Test method

Run it

Expected: \\(10)

The idea

Melvin and SCKelemen made Birb in 2021, after the birds of combinatory logic. Each of fifteen bird emojis stands for a combinator. 🐦 is the identity, 🐥 the kestrel K, 🦢 the substitution S, 🐧 the composition B, 🦩 the cardinal C, 🦜 the mockingbird. Every other character is a comment, so the only syntax error is a program without a bird.

Read the story

The odd part is the order. The birds are not applied left to right. The bird in the middle is applied to by its left neighbour, and from there the term takes one bird from the right, then one from the left, and so on. The specification calls it a stagger. Four birds abcd become (a((bc)d)). The term is then reduced to its normal form.

The machine

BirdLambdaBirdLambda
🦉\ab.b(ab)🐣\abc.c(ab)
🦅\abcde.ab(cde)🐦\a.a
🪽\abcd.a(bd)(cd)🦚\abc.b(ac)
🕊️\abcd.ab(cd)🦤the sage bird Y
🦜\a.aa🐧\abc.a(bc)
🦆\abc.c(ba)🦢\abc.ac(bc)
🐤\ab.b(aab)🦩\abc.acb
🐥\ab.a

A result is printed as the specification writes results. When the normal form is one of the birds, that bird. Otherwise the term in de Bruijn notation, with \ for a lambda, (fx) for an application and 0 for the nearest binder. The specification's table gives the dodo as \ab.a(bb)\ab.a(bb), which is not a fixed point combinator, so this implementation uses the Y it names.

Example

Zero is 🐥🐦 and the successor is 🦢🐧.

Zero is 🐥🐦 and the successor is 🦢🐧. Applied in the stagger, these seven birds make the Church numeral 1.

1 + 2, with the addition 🪽🐧 between a 1 and a 2 built from zero. It takes 3,535 steps.

Expected: \\(1(1(10)))

Two birds can make a third. The phoenix given the identity is S, and the cardinal turns B into the queer bird.

Expected: 🦢
Expected: 🦚

Two parrots never stop. 🦜🦜 reduces to itself and runs until the steps run out.

Patterns it teaches

  • Combinators: S, K, B, C and their friends, each a bird.
  • Lambda encoding: numbers are Church numerals, and a pair of X and Y is 🦩🦩🦩YX.

Further

Functional paradigm

Stack-based

Write your own in Run Convert a program from Birb

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: birb.

Command line

shib run birb -e '🪽🐦'
shib manual birb

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/birb.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org