Declaring Variables and Arrays
Introduction to Declaring Variables and Arrays in Pseudonaja
This guide is going to take you through the process of basic declaration of variables in Pseudonaja.
Basic Variables
To use variables in Pseudonaja we first need to declare the variable. This can be done using the following command:
An example of this is:
You can also use commas to DECLARE multiple variables
Available data types:
INTEGER
A single integer number
REAL
A single float / real number
BOOLEAN
A binary TRUE or FALSE value
CHAR
A single character
STRING
A string of multiple characters
ARRAY
An array of fixed length of a particular data type
To assign a value to a variable, instead of an = sign, an <- is used instead, after the variable has been declared.
Arrays
In pseudocode you declare arrays slightly differently:
An example of this is:
Unlike lists in python arrays can only consist of a single data type as well as a fixed length.
Two dimensional arrays are declared as follows:
An example of this is:
Accessing Arrays
To access a 1D array:
To access a 2D array:
Where the first value within the assignment statement is the row to be accessed, and the second value is the column to be accessed.
Last updated