ToFunction

From Esolang
Jump to navigation Jump to search
This article is not detailed enough and needs to be expanded. Please help us by adding some more information.

ToFunction is a programming language that uses only 3 commands and only uses a string variable type by User:EsolangerII

Syntax

There are only 3 syntax in ToFunction.

Function

It starts with a "define". and needed a function.

define "inputvalue" => "outputvalue";

The First string ('x' => x) is an input value. The second string (x => 'x') is an output value.

When "applied", each character is replaced with its corresponding "definition".

Input

starts with "input"

input "hello";

comments

starts with //

//Hello!

Output

The output infinitely recurs when the output limit is not set. If a limit is set, and when the output is directly equal to the limit, then it stops. setting limit:

limit "1";

Examples

Hello World

input "Hello, World!";
limit "Hello, World!";

duplicator

define "x" => "xx";
input "x";
//output in term 1 : xx
//output in term 2 : xxxx
//output in term 3 : xxxxxxxx
//...

dotmaker

define "x" => ".x";
input "x";
//output in term 1 : .x
//output in term 2 : ..x
//output in term 3 : ...x
//...

addition

//makes a number to x
define "1" => "x";
define "2" => "xx";
define "3" => "xxx";
define "4" => "xxxx";
//delete spaces that are near the plus sign
define "+ " => "+";
define " +" => "+";
//adds a number and pushes the plus sign
define "x+x" => "xx+";
//space works as a timer
define " E" => "E";
//it deletes the plus sign
define "+E" => "E";
//change x to numeral form and set limits.
define "xxxxxxxxE" => "8E";
limit "8E";
define "xxxxxxxE" => "7E";
limit "7E";
define "xxxxxxE" => "6E";
limit "6E";
define "xxxxxE" => "5E";
limit "5E";
define "xxxxE" => "4E";
limit "4E";
define "xxxE" => "3E";
limit "3E";
define "xxE" => "2E";
limit "2E";
define "xE" => "1E";
limit "1E";
//input
input "1 + 2  E";
//output in term 1(step 1) : x+xx  E
//output in term 1(step 2) : xx+x E
//output in term 1(step 3) : xxxE
//output in term 2(step 4) : 3E
//stops

multiplication

//timer + "*" eraser preset
define "P" => "ff  E";
//defining numbers
//added A, B, C, D to find what number is behind "*"
define "1" => "xA";
define "2" => "xxB";
define "3" => "xxxC";
define "4" => "xxxxD";
//same pupose at addition
define "* " => "*";
define " *" => "*";
//multiplication.
//copying number behind and move "*" to front
define "A*x" => "xA*";
define "B*x" => "xxB*";
define "C*x" => "xxxC*";
define "D*x" => "xxxxD*";
//erasing "*"
define "A*f" => "";
define "B*f" => "";
define "C*f" => "";
define "D*f" => "";
define "xAf" => "";
define "xBf" => "";
define "xCf" => "";
define "xDf" => "";
//same purpose as addition
define " E" => "E";
//same pupose as addition
define "xxxxxxxxxxxxxxxxE" => "16E";
limit "16E";
define "xxxxxxxxxxxxxxxE" => "15E";
limit "15E";
define "xxxxxxxxxxxxxxE" => "14E";
limit "14E";
define "xxxxxxxxxxxxxE" => "13E";
limit "13E";
define "xxxxxxxxxxxxE" => "12E";
limit "12E";
define "xxxxxxxxxxxE" => "11E";
limit "11E";
define "xxxxxxxxxxE" => "10E";
limit "10E";
define "xxxxxxxxxE" => "9E";
limit "9E";
define "xxxxxxxxE" => "8E";
limit "8E";
define "xxxxxxxE" => "7E";
limit "7E";
define "xxxxxxE" => "6E";
limit "6E";
define "xxxxxE" => "5E";
limit "5E";
define "xxxxE" => "4E";
limit "4E";
define "xxxE" => "3E";
limit "3E";
define "xxE" => "2E";
limit "2E";
define "xE" => "1E";
limit "1E";
input "3 * 4P";
//output in term 1 : xxxxxxC*xxf  E
//output in term 2 : xxxxxxxxxC*xf E
//output in term 3 : 12E