Pointless.

From Esolang
Jump to navigation Jump to search

Pointless is a point-free variation on 01_.

A Pointless program is a Pointless expression, which is a function that takes a list of bits and returns a list of bits.

Syntax

 program = expr, "." ;
 
 expr = compose | let | if | function ;
 
 compose = expr, expr ;
 
 let = "LET", identifier, "=", expr, { ",", identifier, "=", expr }, "IN", expr ;
 
 if = "(", expr, ",", expr, ",", expr, ")" ;
 
 concat = "(", expr, ",", expr, ")" ;
 
 function = identifier ;

Identifiers are consecutive sequences of non-whitespace characters, excluding (, ), ,, =, and .. Also, LET and IN are reserved and may not be used as identifiers. Whitespace separates identifiers and is otherwise ignored.

Comments begin with == and extend to the end of the line.

Expressions

Compose

 f g

This is a function that returns the result of applying f to the result of applying g to its argument.

Let

 LET f = (_,0,1) IN f.

A LET expression binds one or more identifiers, which may be referred to in the body of the expression or in the bodies of the bindings. Bindings in a LET may shadow bindings in any enclosing scope, including the initial scope. This function is the body of the LET expression, f in the above example.

If

 (f,g,h)

If the argument of this is an empty list, it returns the result of applying f to its argument.

If the head of the argument is 0, it returns the result of applying g to the tail of its argument.

If the head of the argument is 1, it returns the result of applying h to the tail of its argument.

Concat

 (f,g)

This is a function that returns the concatenation of the result of applying f to its argument and the result of applying g to its argument.

Function

A function may be an identifier bound in an enclosing LET expression or bound in the initial scope. The initial scope consists of

  • _ ignores its argument and returns an empty list
  • 0 returns its argument with 0 prepended
  • 1 returns its argument with 1 prepended

Examples

Hello world

 0 0 0 1 0 0 1 0  1 0 1 0 0 1 1 0  0 0 1 1 0 1 1 0  0 0 1 1 0 1 1 0
 1 1 1 1 0 1 1 0  0 0 0 0 0 1 0 0  1 1 1 0 1 1 1 0  1 1 1 1 0 1 1 0
 0 1 0 0 1 1 1 0  0 0 1 1 0 1 1 0  0 0 1 0 0 1 1 0  1 0 0 0 0 1 0 0
 0 1 0 1 0 0 0 0  _.

Cat

 (_,0,1).

References