Lazy K

From Esolang
Jump to navigation Jump to search

Lazy K, designed by Ben Rudiak-Gould, is a Turing tarpit based on combinatory logic. It is lazily evaluated and purely functional.

History

Lazy K was designed to address a shortcoming of Unlambda; namely, its lack of functional purity. Lazy K's author felt that the functional programming paradigm needed an analog to the imperative paradigm's Brainfuck, and Unlambda was simply not it.

Lazy K was submitted to the 2002 Esoteric Awards.

Instructions

Lazy K is based on the SKI combinators. It provides several syntaxes for representing them:

  • Combinator calculus style: S, K, and I characters are used to represent those combinators, with parentheses for disambiguation.
  • Unlambda style: s, k, i, and a binary application operator ` are used.
  • Iota and Jot style, each using the notation from its respective language.

i is a valid expression in both Unlambda and Iota, and with different meanings, so the Unlambda meaning takes precedence in this case.

Input and output

Rather than side effects, input and output in Lazy K are "front- and back-effects". A program is treated as a function mapping all possible inputs to all possible outputs.

Characters are represented as Church numerals from 0 to 255, with 256 indicating end of file. The list of input characters is infinite, and the first 256 is followed by an infinite number of 256s.

Any characters following the first number of 256 or greater in the output list are not used. The reference implementation returns n-256 as an exit code, where n is the number terminating the output list.

Lazier

The implementation of Lazy K provides a meta-language, consisting of the lambda calculus written in Scheme notation, which can be compiled into Lazy K. Many of the example programs are written in this.

Hello world

`k``s``si`k``s`k```sii``s``s`kski``s``s`ksk``s``s`ksk```s``siii``s``s`kski`k``s``si`k``s``s`ksk```s``s`ksk
i``s`k``s``s`kski``s``s`ksk```sii``s``s`kski`k``s``si`k``s`k```sii``s``s`kski```sii``s``s`ksk``s``s`kski`k
``s``si`k``s`k```sii``s``s`kski```sii``s``s`ksk``s``s`kski`k``s``si`k``s``s`ksk``s`k``s``s`kski``s``s`ksk`
`s`k``s``s`kski```sii``s``s`ksk``s``s`kski`k``s``si`k````s``s`ksk```s``siii``s``s`kski`s``s`ksk```sii``s``
s`ksk``s``s`kski`k``s``si`k``s`k``s``s`kski```s``siii``s``s`kski`k``s``si`k``s`k``s``s`ksk``s`k``s``s`kski
``s``s`ksk``s``s`kski``s``s`ksk```s``siii``s``s`kski`k``s``si`k``s``s`ksk``s`k``s``s`kski``s``s`ksk``s`k``
s``s`kski```sii``s``s`ksk``s``s`kski`k``s``si`k``s`k``s``s`kski``s``s`ksk``s`k``s``s`kski``s``s`ksk```sii`
`s``s`ksk``s``s`kski`k``s``si`k``s`k```sii``s``s`kski```sii``s``s`ksk``s``s`kski`k``s``si`k```s``s`kski``s
`k``s``s`kski``s``s`ksk```sii``s``s`kski`k``s``si`k``s``s`ksk``s`k``s``s`kski```s``siii``s``s`kski`k``s``s
i`k``s`k``s``s`kski``s``s`ksk```sii``s``s`kski`k``s``si`k```sii```sii``s``s`kski`k```sii```sii``s``s`kski

See also

External resources