The Sababa Programming Language

Lists

A list, array, or whatever else you'd like to call it, is a collection of multiple primitive types, which can contain variables. It is a feature which is present in Sababa, and its structure is as follows:

Literal List Declaration

  • {"anything" "can" "go" "here" 1}

You can combine different primitive types within a list, as you see above, there are both strings and an integer. A space represents the separation between the list indices.

Declaration Through List Function

  • list 1 2 3 4 "hello"

You begin using the list function, and separate the elements with a space. Once again, different primitive types may be combined within a list.

An example of both list declaration is:

sababa> {1 2 3 "Hello"}

=> {1 2 3 "Hello"}

sababa> list 1 2 3 "Hello"

=> {1 2 3 "Hello"}

sababa> def{listVar} {1 2 3 4}

=> ()

sababa> print listVar

=> {1 2 3 4}

=> ()

The last example, I set a list value to variable listVar, and printed it to the screen.

Multi-dimensional Arrays

Sababa supports multi-dimensional arrays, which are arrays within arrays, or lists within lists in our context.

An example of this is as follows:

sababa> {1 2 3 {"one" "two" "three"}}

=> {1 2 3 {"one" "two" "three"}}

P.S. There are some built-in functions that relate to lists, which I will cover in a later chapter.