Skip to content
Mohamed Essam edited this page Sep 12, 2013 · 2 revisions

Defining a variable:

The let statement can be used to define variable and put an initial value in them

let VARIABLE_NAME = VARIABLE_VALUE;

Example: let x = 0;

You can define multiple variables in one line using a comma as a separator

Example: let x = 0, y = 5;

Accessing a map:

A map can be accessed through the brackets '[]' operator

Example: let x[2] = 0;

Example: let x[0][2] = 3;

Input/Output


Printing a variable

The print statement can be used to print any variable or expression.

print EXPRESSION;

Example: print (x*5)^2;

You can print multiple expressions in one line using a comma as a separator

Example: print (x*5)^2, x*10;

Scanning a value from input

The scan statement can be used to scan a variable (even if it wasn't defined)

scan VARIABLE;

Example: scan x;

You can additionally specify the type to be scanned (default will decide between number and string) using the as keyword

Example: scan x as integer;

Types available:

  1. 'string': scans a string and stops at white spaces, e.g: if input was 'some input', this will scan 'some'.
  2. 'number': scans an optionally floating number stops at white spaces, e.g: if input was '5.3 6.2', this will scan '5.3'.
  3. 'integer': same as 'number', But converts the returning value to an integer value, e.g: if input was '5.3 6.2', this will scan '5'.
  4. 'line': scans a whole line as a string stopping only at newlines, e.g: if input was 'some input', this will scan 'some input'.

You can scan multiple variables in one line of the same type.

Example: scan x, y as integer;