LOLA

From Esolang
Jump to navigation Jump to search

LOLA (Lots Of Lambda Abstractions) is a minimalistic functional programming language devised by User:Smjg. It is based on lambda-calculus.

LOLA is purely functional both in the usual sense (functions do not have side effects) and in the sense David Madore has used to describe Unlambda (functions are the only objects).

A LOLA program consists of a number of function definitions, each of which is a single line of code. Functions are created by writing lambda abstractions in a notation based on de Bruijn indexes. Functions can also be applied to other functions to create new functions. There are no built-in functions in LOLA.

Execution consists of evaluating the main function and then applying it to the Church integers 0 and 1 to determine an input or output event and a new expression on which the process is repeated. LOLA's I/O model uses Church integers to represent character codes.

Code example

The "Hello, world!" program can be written in LOLA as follows:

 comments are anything between space and EOL

+\\\cb,ba,, actually the increment function, so that 6+, adds 6 to its argument
*\\\cba,,   multiplication of Church integers is function composition
:\\\a\c,c,  cons function

 this function has no name, so it is the main function
 (the order of function definitions is immaterial)
:H,:e,:l,:l,:o,:',:_,:w,:o,:r,:l,:d,:!,:%,:\\b,\\a,,,,,,,,,,,,,,,

 define the various Church integers in terms of each other
H*6,^,
e+d,
l8+,d,
o3+,l,
'_+,^,
w8+,o,
r+^,+,e,
d2%,
_52,
!+_,

2\\bba,,
3+2,
422,
5+4,
6*2,3,
832,
%*2,5,
^*2,6,

Computational class

LOLA provides the full power of lambda-calculus, which is known to be a Turing complete system. Consequently, LOLA is Turing complete.

External link