Grass (2)

From Esolang
Jump to navigation Jump to search

Grass (2) is an extension of the programming language Grass designed by User: Tpaefawzen in 2026 (1) to accept the application /W+w+/ as the first statement of the program in addition to the abstraction /w+(W+w+)*v?/; and (2) to be able to return arbitrary position of the value from the function.

Description for feature (1)

With the extension above, the program to output "w" can be written as follows:

Wwww

which is shorter than of original Grass:

wWWwwww

Description for feature (2)

Change the syntax for function definition:

Function = Args Body Return EndOfFunction
Args = w+
Body = App*
App = W+ w+
Return = W*
EndOfFunction = EndOfFile | v+

With Return, the Function would return the n-th last argument when it has n letters of uppercase W and n is 0-indexed.

For example the following function takes two items and returns latter one:

wwv

while the following function also takes two items to return former one:

wwWv

And the following function takes one argument but ignores it to return last function:

wWv

This returns second last function, and so on:

wWWv