Skip to content
Julius Paffrath edited this page Jul 5, 2026 · 8 revisions

Introduction

Lists are a very powerful kind of variable and can store any type of data. Creating a list is easy:

set myList to list()

Creating a new list with elements is easy as well:

set myFruits to list("Apple", "Orange", "Banana")

If you add an element to a list, it will be appended at the end of the list:

set myFruits to listAdd(myFruits, "Cherry")

As you can see, all list functions are returning copies, so you have to store the result. For example this:

listAdd(myFruits, "Cherry")

does not alter the variable myFruits! It just creates a copy which, in this case, is not assigned so the interpreter discards it.

Special case: strings

A string in jask can be treated as an implizit list of characters, see the following example:

print(listGet("12345", 3))

This will print the string "4".

Complete reference with named parameters

list(param1: any, param2: any, ...)

Returns a new list containing the given elements. Please note that list() does not support named parameters.

listSize(list: [list|string])

Returns the size of the given list or number of characters in a list.

listAdd(list: [list|string], element: any)

Adds the given element to a copy of the given list and returns the copy. If a string is passed as the first parameter, the element to add must be a string as well. In this case, a new string will be created with the element added at the end.

listGet(list: [list|string], index: number)

Returns the element at the given index in a list or a character in a string.

listGetRange(list: [list|string], indexStart: number, indexEnd: number)

Returns the elements in the given range in a list or a substring in a string.

listSet(list: [list|string], index: number, element: any)

Sets an element at the given index to a copy of the given list and returns the copy. If a string is passed as the first parameter, the element to be set must be a string as well. In this case, a new string will be created with the given string replaced at the given index. Please notice: If the string element is longer than one character, following characters in the string will be overwritten.

listRemove(list: [list|string], index: number)

Removes the element at the given index in a copy of the given list and returns the copy. If a string is passed as the first parameter, a copy of the string is returned with the charater at the provided index removed.

listReverse(list: [list|string])

Creates a reversed copy of the given list or string and returns the copy.

listExtend(list: [list|string], expander: [list|string])

Creates an expanded copy of the given list and returns the copy. If the first parameter is a string, the expander must be a string as well. This will create a new merged string. Please note: This is included solely for the sake of linguistic completeness. It is much more efficient, merging two strings using the + operator.

Clone this wiki locally