Grass

From Esolang
Jump to navigation Jump to search

Grass is a functional grass-planting programming language. Its unique characteristic is that it is said to be easy to slip into ASCII art.

Grass is based on lambda calculus, and the program consists of a list of abstractions and applications of functions, using only the characters W, w, and v.

Overview

The following six characters are valid characters for Grass, and others are ignored:W, w, v, , , and . The three full-width characters are semantically identical to each corresponding half-width character. A program in Grass is considered to be a sequence of functions. Tokens beginning with W are application and those beginning with w are abstraction. v separates tokens.

Grass has a SECD machine as a virtual machine. Its environment is initialized with four primitive functions: Out, Succ, integer 119 (or character 'w'), and In.

The Out function takes one argument, an integer, to output it as an ASCII character. It must be an integer or else the program will abort. The Succ function takes one argument, an integer , to return . Integer can be both an argument of a function and a function itself. As a function, it takes one argument to return if the integer value and that of its argument are equal, as a Church boolean ( and for true and false respectively). The In function takes one argument, reads a character from stdin, and returns it on success or returns the argument instead if EOF is encountered.

Examples

The following code prints a single 'w'.

wWWwwww

The following code prints 'w' forever.

無限に草植えときますねwWWwwwwWWww

The following code calculates and prints the result as a number of 'w's.

wwWWwv
wwwwWWWwwWwwWWWWWWwwwwWwwv
wWWwwwWwwwwWwwwwwwWwwwwwwwww

External resources