ToArrowScript

From Esolang
Jump to navigation Jump to search

ToArrowScript(or TAS, AS) is a language created by User:Cycwin.This language is partly inspired by the => (arrow) symbol in JavaScript.

Syntax of TAS

Use the ampersand symbol to separate each line of command. Each command is composed in a format similar to the following.

(0) => add <= (1) <= (2)

You can see that (0), (1), and (2) all point to the function named add. Then this function will receive the three parameters of (0), (1), and (2) in sequence. The creation of variables is similar to the writing of commands.

_variable <= (0)

This command sets the variable (or _variable) to (0).TAS has two built-in variables. They are output and input. Changing the output variable (append content) will output the appended content. The output variable can only be appended. As long as the input variable is accessed, the input is obtained from the standard input stream once and is used as the value of the input variable. To access two system variables, add - instead of _. For example:

-output => (-input)

Read the user input and output.In the variable definition, $ represents the current value of the variable.

_variable <= (0)&
_variable <= ($+1)

This code will set the variable to 0 and increment by 1.


TAS has three types of data: value, group, code.The value is enclosed in parentheses, it supports string in "s, for example:

(15+27)

An operation can be performed within the value.The plus sign is used to add two numbers or concatenate groups or concatenate codes. The minus sign and other operations (multiplication, division, remainder) are only valid for numbers.The comparison symbols are >, <, =, respectively to determine whether one value is greater than, less than, or equal to another value. ?, |, ! respectively and, or, non-gate.

((0-1)<2)

This value is equivalent to (1). The group is enclosed in square brackets. There can be multiple values or codes within a group. Separate them with commas.Some functions of the group can be called by using single quotes and function names after the group.

  1. slice function.Accepts two parameters and returns a slice of the group between these two values.
    [(0), (4), (2)]'slice <= (0) <= (2)
    Returns [(0), (4)].
  2. pop function.accept a parameter. Returns the original group whose value position is deleted.
    [(0)]'pop <= (0)
    Returns [].
  3. push function.accepts two parameters and returns the original group that inserts the second parameter value in the first parameter value.
     []'push <= (0) <= (0) 
    returns [(0)].
  4. element function.Accepts a parameter that returns the value at the specified location of the group.
     []'element <= (0)
    will report an error because the group is empty.
  5. length function.No parameters are accepted, and the length of the group is returned.
    [(0), (2)]'length
    Returns (2).

The TAS command is placed in the code type, but the & is changed to;.If parameters are passed, -a, -b... indicates the parameters passed in sequence. The return value is placed outside parentheses.Code types are enclosed in curly brackets.The TAS function provides a private giving variable, which can be accessed by "-giving_function name" in other functions.


TAS has some built-in functions.Now we call the first parameter -a, the second one -b, and so on.

  1. If. If -b is not 0, run -a 1 time.
  2. For. Create a variable with -c as the variable name, and use this variable to iterate through -b (group), executing -a every time iterates.
  3. While. -b should be code. If -b does not return 0, run -a. Then check -b again.
  4. Array. Returns an array of length -a, each with a value of (0).
  5. toASCII. Accept the number -a and return the -ath value in ASCII.
  6. inASCII. Returns the position of the character -a in ASCII.


Use ":" Comment.

Examples

Cat Program

:Cat Program&
{-output<=(-input)} => while <= {}1&

Calculate 5!

_f <= {
_number <= (-a) ;
_counter <= (0) ;
_return <= (1) ;
{
 _counter <= ($+1) ;
 _return <= ($*(_counter)) ;
} => for <= ("i") <= ((_number) => array)}(_return) &
-output <= ((5) => f) &
:output 120.

Interpreter

We have no interpreter now...


Keep happy everyday!