Skip to content
This repository has been archived by the owner on Mar 17, 2022. It is now read-only.

Example 5

Stanislav Mikhel edited this page Jun 10, 2017 · 1 revision

VPSYS uses 3 main types of data: strings, number (include logical values) and arrays of numbers.

String is a sequence of characters inside the double quotes. In VPSYS strings are used mostly as a comments. The only available operation with strings is concatenation, which is denoted with +. Type of the complex equation is defined by the first term.

 "One," + "two"         # variable %ans contains "One,two"
 %s1 = "" + 1 + 2 + 3   # variable %s1 contains "123"
 %s2 = "" + (1 + 2 + 3) # variable %s2 contains "6"

Array is an ordered set of elements (numbers in our case), and each element can be called using its index. Default number of dimensions is 1, maximal number is 10. Indexation begins from 0. Following example shows some of possible operations.

 %a = [1,2,3,4,5]       # listing of elements can be used for initialisation
 %a[0] + %a[1]          # indexes are also in square brackets
 %a : [2,3]             # create array with dimensions 2x3, elements are not initialised
 %a = [-1,-2,3]         # initialize elements sequentially, other are zeros
 %a[0,2]                # use coma to separate indexes in multidimensional array
 %a = 10                # set every elements to 10

After resize elements saves their values. It allows, for example, transform 4x1 into 2x2.

Clone this wiki locally