From Esolang
Jump to: navigation, search

(), pronounced "parens", is a daughter of iota midwived by User:Dankogai which source code consists entirely of '(' and ')'.


This language's code consists of three lambda calculus-expressed functions:

<math> \begin{align} S&=&\lambda x.\lambda y.\lambda z.x(z)(y(z))\\ K&=&\lambda x.\lambda y.x\\ U&=&\lambda x.x(S)(K) \end{align} </math>



 var S = function(x){return function(y){return function(z){return x(z)(y(z))}}};
 var K = function(x){return function(y){return x}};
 var U = function(x){return x(S)(K)};
 var iota2jsstr = function(str){
   return (function(a){
       if (!a.length) throw 'syntax error';
       return a.shift() === 'i' 
           ? 'U' 
           : arguments.callee(a) + '(' + arguments.callee(a) + ')';
   })(str.replace(/[^\*i]/g, ).split());
 var iota = function(str){ return eval(iota2jsstr(str)) };
 var iota2parens = function(str){
   return iota2jsstr(str).replace(/[^\(\)]/g, );
 var parens2jsstr = function(str){
   return str.replace(/\(/g, 'U(')
               .replace(/U\(\)/g, 'U(U)')
                   .replace(/\)U\(/g, ')(');
 var parens = function(str){ return eval(parens2jsstr(str)) };


 (define S (lambda (x) (lambda (y) (lambda (z) ((x z) (y z))))))
 (define K (lambda (x) (lambda (y) x)))
 (define U (lambda (x) ((x S) K)))
 (define (%parens base compose)
   (lambda (code)
     (let r ((c code))
       (unless (list? c) (error "proper list required, but got" c))
       (fold (lambda (a b) (compose b (r a))) base c))))
 (define parens        (%parens U (cut <> <>)))
 (define parens->lisp  (%parens 'U list))
 (define parens->jsstr (%parens "U" (cut string-append <> "(" <> ")")))

Computational class

Turing complete, just as mother (also a twin sister!) iota is.

Notable Characteristics

  • a valid () code is always one symbol shorter than its corresponding iota code.
  • the I combinator happens to be '()'.

External resources