Lazy Bird

From Esolang
Jump to: navigation, search

Lazy Bird is a functional esoteric programming language designed by user:Slereah, based on Unlambda (with lazy evaluation) and inspired by To mock a mockingbird . It uses the usual basic instructions :

  • ` : Apply operator
  • s,k,i : Primitive combinator
  • .x,r : Identity combinator with printing x/line feed as a side effect.

And the following combinators and instructions :

  • m : Mockingbird combinator. `mx converts to `xx (``sii conv. m)
  • 0 : Kite combinator. ``0xy converts to y (`ki conv. 0)
  • w : Warbler combinator. ``wxy converts to ``xyy (``ss`ki conv. w)
  • u : Turing combinator. ``uxy converts to `y``xxy (``s`k`si``sii conv. u)
  • o : Owl combinator. ``oxy converts to `y`xy (`si conv. o)
  • t : Thrush combinator. ``txy converts to `yx (``s`k`sik conv. t)
  • l : Lark combinator. ``lxy converts to `x`yy (``s``s`ksk`k``sii conv. l)
  • b : Bluebird combinator. ```bxyz converts to `x`yz (``s`ksk conv. b)
  • c : Cardinal combinator. ```cxyz converts to ``xzy (``s``s`k``s`ksks`kk conv. c)
  • q : Queer combinator. ```qxyz converts to `y`xz (``s`k`s``s`kskk conv. q)
  • v : Vireo combinator. ```vxyz converts to ``zxy (``s`k``s``s`k``s`ksks`kk``s`k`sik conv. v)
  • @ : Equivalent to Iota's i.
  • # : Equivalent to Unlambda's v.
  • _ : Input. Converts the ASCII value of the input into Church numerals. (Has the problem of being difficult, if not impossible, to evaluate at the right moment once and for all without some sort of anti-d operator. Ideas welcome)
  • & : Delta operator. Returns k for ``&xx (two identical combinators), or 0 for ``&xy, x different from y. Identical means written the same way, or only differing by an alpha conversion for a lambda expression.
  • a,n,p,x : Dummy combinators. Never evaluates to anything. Used for function testing.

It also accepts a mix of combinators and lambda calculus, with Polish notation or parentheses. Whitespace is ignored apart from space, and all capital letters not after . are turned into lower case. The lambda notation is of the form M, `MN or ^aM, , where M and N are other lambda expressions (A free variable will either generate an error or be interpreted as an existing combinator with the same letter). For instance, the addition function is :


And this program will print seven times * :


Since there's no difference between a variable and a combinator, s, k and i are forbidden as variables (as well as . and ^). Since the eliminator of abstraction only works with ski combinators, any other letter isn't technically a problem, but do not use a variable name identical to another combinator you intend to use. This eliminator is more efficient, since it converts the expression to ski-bc.

The program will stop if no more applications are possible (Usually meaning that the expression is identical to the previous step)

A few functions

  • Successor, addition, multiplication, exponentiation : `sb, `t`sb, b, t
  • 0 through 5 : 0, i, ``sbi, ``sb``sbi, `m``sbi, ``sb`m``sbi, ...
  • True, false, and, or, not, is zero : k, 0, `wc, m, ``c`t0k, ``v`k0k
  • Xor, eq, nor, nand : ``c``bs`q``tk`v0i, ``cs``c`t0k, ``c``bb`t0``c`t0k, ``c``bc`q``c`t0kk
  • Predecessor : ``c``bc``b`bc``c``bc``b`bb`q`c`btki
  • Subtraction : `c`t``c``bc``b`bc``c``bc``b`bb`q`c`btki
  • Cons, car, cdr : v, `tk, `t0

And so on


Hello, world!

`````````````.h.e.l.l.o.,. .w.o.r.l.d.!i

Cat program (sort of)

``uu`_.* (Prints the ASCII number of the character of *)

Fibonacci sequence

``m^x^y````yk.1r``xx``v`y0```yk`sb`y0``v0i (Prints the result in unary)

In full combinators :


Prints out n *, then n-1, and so on until 0, then stops.

`bc``c``bc``b`bb`q`c`btkii[Add some Chuch numeral here]

External ressources

Interpreter (comment or uncomment "print "Expression : ", lambexp" to displaying the evolution of the expression or not) Combinator birds