-
Notifications
You must be signed in to change notification settings - Fork 0
List variables in jask
List variables in jask can store any type of data, even dictionaries, structs and other lists. Creating a new list is straight forward:
store list() in myList
Creating a new list with elements is easy as well:
store list(VAR1:VAR2...:VARN) in myList
If you add an element to a list, it will be appended at the end of the list:
assign listAdd(myList:VAR) to myList
Because all list functions are returning copies, you have to assign the results.
To access elements, use the index starting with 0 (zero):
store listGet(myList:INDEX) in myElement
or obtain all elements inside a range:
store listGetRange(myList:START:END) in myElements
If you want to set an element at a specified index:
assign listSet(myList:INDEX:VAR) to myList
Or to remove elements from your list:
assign listRemove(myList:INDEX) to myList
Remove elements in a range:
assign listRemoveRange(myList:START:END) to myList
Obtaining the size of a list:
store listSize(myList) in listSize
Check if a list contains an element:
print(listContains(myList:VAR))
Reverse the elements inside a list:
assign listReverse(myList) to myList
Extend a list with another list:
assign listExtend(myList:list(1:2:3)) to myList
Functions for string processing are supported too:
store listFromString("This string will be a list!") in myStrList
...and backwards:
print(listToString(myStrList))
Visit Internal Functions Wiki to see all implemented list functions.
- Home
- Getting started
- Control flow
- Functions
- List variables in jask
- Dictionary variables in jask
- Structs in jask
- Convert variables
- Internal Functions
- The access operator
- Callbacks in jask
- Modules
- Internal Modules
- The jask standard library jcore
- Using CMD arguments in jask
- Nested function calls
- Functions inside functions!
- Modules inside functions!
- Performance comparison of loops