()

From Esolang
Jump to navigation Jump to search

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

Instructions

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

Implementations

JavaScript

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)) };

Scheme

 (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 () program is always one symbol shorter than its corresponding Iota program.
  • The I combinator happens to be '()'.

External resources