Birb

From Esolang
Jump to navigation Jump to search
Birb
Paradigm(s) functional
Designed by User:Melvin, User:SCKelemen
Appeared in 2021
Type system untyped
Memory system stack-based
Computational class Turing complete
Reference implementation [1]
Influenced by Combinatory Logic, Lambda Calculus, Gabriel Lebec, Samuel Kelemen
File extension(s) .birb, .bird,

Birb is an untyped, purely functional language based on Lambda Calculus and Combinatory Logic.


Language overview

The birb language is entirely comprised of bird emojis.

Symbols

Symbol Name Lambda Calculus Combinator
πŸ¦‰ owl \ab.b(ab) owl
πŸ¦… eagle \abcde.ab(cde) eagle
πŸͺ½ wing \abcd.a(bd)(cd) phoenix
πŸ•ŠοΈ dove \abcd.ab(cd) dove
🦜 parrot \a.aa mockingbird
πŸ¦† duck \abc.c(ba) quacky
🐀 touring chick \ab.b(aab) turing
πŸ₯ kool chick \ab.a kestrel
🐣 hatching chick \abc.c(ab) quirky
🐦 simple bird \a.a identity
🦚 peacock \abc.b(ac) queer
🦀 dodo \ab.a(bb)\ab.a(bb) sage
🐧 penguin \abc.a(bc) blackbird
🦒 swan \abc.ac(bc) substitution
🦩 flamingo \abc.acb cardinal

Syntax

  • [birb]+: Birb
  • everything else: Comment

Syntax errors are impossible as long as you use at least one birb.

Semantics

Birbs stagger as they walk: they are reduced in alternating associative order, starting with left associativity at birb index ⌊len/2βŒ‹:

   🐦🐦 -> (🐦🐦)
   🐦🐦🐦 -> ((🐦🐦)🐦)
   🐦🐦🐦🐦 -> (🐦((🐦🐦)🐦))
   🐦🐦🐦🐦🐦 -> ((🐦((🐦🐦)🐦))🐦)
   🐦🐦🐦🐦🐦🐦 -> (🐦((🐦((🐦🐦)🐦))🐦))
   🐦🐦🐦🐦🐦🐦🐦 -> ((🐦((🐦((🐦🐦)🐦))🐦))🐦)
   ...

Examples

You can find more examples (with comments) in the samples/ directory.

Relationships

  • πŸͺ½πŸ¦ -> 🦒
  • 🦒🐦 -> πŸ¦‰
  • πŸ¦‰πŸ¦ -> 🦜
  • πŸ•ŠοΈπŸ¦ -> 🐧
  • 🐧🐧 -> πŸ•ŠοΈ
  • 🦩🐧 -> 🦚
  • 🦩🦚 -> 🐧
  • πŸ¦©πŸ¦† -> 🐣

One can only imagine what happens if two parrots talk to each other: 🦜🦜 -> πŸ’₯. The same happens with 🐀🐀; they just can’t stop waddling!

Arithmetic

For this example I use the Church numerals. Zero would then be encoded as πŸ₯🐦. The successor function can be written as 🦒🐧:

  • 🐦🐧🐦🦒🐧πŸ₯🐦 -> \\(10) (Church numeral 1)
  • πŸ¦πŸ§πŸ¦πŸ§πŸ•ŠοΈπŸ¦’πŸ§πŸ¦’πŸ§πŸ₯🐦 -> \\(1(10)) (Church numeral 2)

Similarly, one can translate the Church addition function to πŸͺ½πŸ§. Now, to calculate 1+2 based on their increments from zero:

  • πŸ¦πŸ¦πŸ•ŠοΈπŸ§πŸ•ŠοΈπŸ§πŸ¦πŸ§πŸ•ŠοΈπŸ§πŸ•ŠοΈπŸͺ½πŸ§πŸ¦’🐧🦒🐧πŸ₯🐦🦒🐧πŸ₯🐦 -> \\(1(1(10))) (Church numeral 3)

Also: 🐧 is a*b, 🦜 is n^n and 🦚🐦 a^b.

Note that there exist many alternative ways to do arithmetic. Try writing the functions above with other birbs!

Containers

You can create a pair [X,Y] using 🦩🦩🦩YX.

Typically, one would now construct a list using repeated application of pairs (Boehm-Berarducci/Church encoding). However, due to the reversed application and alternating associativity, the Mogensen-Scott encoding is more suitable:

List [X_1,X_2,...,X_n]: [🦩]ⁿ🦩X2X1...XN.

Turing-completeness

Birb is Turing complete, since one can construct any term of the Jot variant of Iota. A Jot term ((X s) k) is equivalent to 🐦🐦X🦒πŸ₯. Similarly, (s (k X)) is equivalent to πŸ¦πŸ¦†XπŸ₯🦒.

Implementations

As of right now there is one interpreter, written by User:melvin in Haskell: [2]. It also features a BLC to birb transpiler.