Sage-Code Laboratory
index<--

Wee Collections

Collections also known as composite data types are actually user defined data types.

Ordinal

Is an enumeration of symbols ordered by position.

** create ordinal type
def type_name : {symbol, ...};

** create a variable with initial value one identifier
new new_name  : type_name.symbol;

Note:

Array

Array has a capacity and a data type.

array_type
new array_name : [type](capacity)
let array_name : [1,2,3,4,5] ; array literal 

Slice

Slice is a section from an array.

new array_name :[0](100) ; array of 100 numbers
new slice_name :array_name[0..10] ; slice of first 10 

Object

def class_name  :{name:type, ...}
new object_name :{name:value, ...}

Note: Empty object is represented like this: {}

String

Strings are arrays of ASCII symbols:

syntax:

new string_name : [''](capacity)
A string literal is enclosed in double quotes: ""

example

** string with capacity of 20 symbols
new test : [''](20) 

** initialize the string with literals
let test : "this is a string"

Read next: Wee Index