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, element: any)

Adds the given element to a copy of the given list and returns the copy.

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, index: number, element: any)

Sets an element at the given index to a copy of the given list and returns the copy.

listRemove(list: list, index: number)

Removes the element at the given index in a copy of the given list and returns the copy.

listReverse(list: list)

Creates a reversed copy of the given lists and returns the copy.

listExtend(list: list, expander: list)

Creates an expanded copy of the given list and returns the copy.

Clone this wiki locally