Variable and Constant

 

| HOME |

Variable

A variable in Noobeed can have a length of up to 1000 characters, and it must fulfill the following conditions.

  • it starts with a letter, i.e. A-Z and a-z.

  • it must followed by letters, A-Z and a-z, or numbers, 0-9, or the under-score sign "_".

  • it is case-sensitive.  Thus "a" and "A" are different variables.

  • It must not be one of the reserved words of Noobeed.  Reserved words are commands, class names, global function names and the word "void".

To view existing variables, use command "list var", or "flist var".   To clear existing variables, use command "clear" followed by variables name delimited by space, or use command "clear all" to clear all existing variables.

To view the content of a variable, use command "print" followed by the variable name, or just type the name of the variable and press enter key.

 

Constant

There are 3 types of constants in Noobeed, namely numerical constant, string constant and matrix constant.  

A numerical constant consists of numbers and must not have a space, blank, in it.  It is always interpreted as a type of double precision.  Other types of numerical constants, such as integer, float, short, etc., must declare by using a global function, for example int(12), float(50).  See example below.

A string constant is any legal character surrounded by two double quotation signs.  One at the beginning and the other at the end.  Legal characters are listed in statement and syntax section.

A matrix constant is created by putting numbers inside a pair of brackets.  Each number is a value of an element in a matrix.  Numbers are separated by one or more spaces, and a semi-colon ";" sign is used to separate rows in a matrix.  Expressions inside the bracket are possible, however, each element now must be separated by a comma ",".  To get more understanding, please see examples.  Sub-matrices can also be put together to build a larger matrix, see the last two examples below.

Please consider the following examples.

->a = 10

a numerical constant and is interpreted as double precision

->a = -.5

a numerical constant and is interpreted as double precision

->a = -1.526e+80

a numerical constant and is interpreted as double precision

->a = int(9)

a numerical constant of integer type

->b = "My name"

a string constant

->c = "My name " + "is ..."

two string constants connect to each other

->d = [ 1 2 3; 4 5 6]

a matrix of 2 rows and 3 columns

->e = [ 1, 2,sin(45); 6, 7,8]

a matrix of 2 rows and 3 columns.  Notice the use of comma ",".

->f = [d e; e d]

a matrix of 4 rows and 6 columns

->f = [d*5, e*6; e-3, d+5]

a matrix of 4 rows and 6 columns.  Notice the use of comma ",".


| HOME