Lazy

From Esolang
Jump to: navigation, search
This article is a stub, which means that it is not detailed enough and needs to be expanded. Please help us by adding some more information.

Created by User:MagiMaster in 2006 (and conceived much earlier). Its main goal is to use lazy evaluation and have functions as first-class objects. Also, it tries to do everything as a function definition.

Currently this specification is incomplete.

Example

A simple example is the cat program:

main()=output(input())

Another example:

fib(0)=1
fib(1)=1
fib(n)=+(fib(-(n,1)),fib(-(n,2)))
main()=output(fib(input()))

Built-in functions

  • +(x,y), -(x,y), *(x,y), /(x,y), %(x,y)
  • input(), output(n)

Computational class

Lazy is Turing-complete as it includes the μ-recursive functions. To show this, the only non-trivial function to define is μy f(y,x1,...,xk) (which does not actually have y as parameter, y is bound by the μ), which for a specific f can be given as follows:

μy f(y,x1,...,xk) = g(0,x1,...,xk)
g(n,x1,...,xk) = if0(f(n,x1,...,xk),n,g(+(n,1),x1,...,xk))
if0(0,a,b) = a
if0(n,a,b) = b