Return to index

list functions

all()

top

Example:

# Example for all
println all([1,1,1])  # true


any()

top

Example:

# Example for any
println any([0,1,0])  # true


[]mixed = append([list,]item)

top

Returns new_list containing item appended to list. If list is omitted then a new list is created containing item.

Example:

# Example for append
var lst=[1,2,3]
lst=append(lst,4)
println lst  # [1,2,3,4]


bool_success = append_to(list_name,item)

top

Appends item to local_list_name. Returns bool_success depending on success.

Example:

# Example for append_to
append_to("list",[1])


number = avg(list)

top

Calculate the average value in a list. Supports multi-dimensional arrays.

Example:

# Example for avg
println avg([1,2,3])  # 2


[]string = col(string,column[,delimiter])

top

Creates a list from a particular column of line separated string.

Example:

# Example for col
println col("a b\nc d",2)  # ["b","d"]


[]new_list = concat(list,list)

top

(deprecated) Concatenates two lists and returns the result.


bool = empty(list)

top

Is list empty?

Example:

# Example for empty
var lst=[1,2,3]
println empty(lst)  # false


bool = eqlen(list_of_lists_or_strings)

top

Checks that all lists or strings contained in the input are of equal length.

Example:

# Example for eqlen
println eqlen([[1,2],[3,4]])  # true


bool = esplit([]list,"var1","var2",pos)

top

Split list at position pos (1-based). Each side is put into variables var1 and var2.

Example:

# Example for esplit
var lst=[1,2,3,4,5]
esplit(lst,"l","r",3)
println l  # [1,2]
println r  # [3,4,5]


new_string = fieldsort(nl_string,field[,sort_type][,bool_reverse])

top

Sorts a newline separated string nl_string in ascending or descending (bool_reverse==true) order on key field.

Example:

# Example for fieldsort
var text="4 one\n2 two\n3 three\n1 four"
println fieldsort(text,1,"n",false)


item = head(list)

top

Returns the head element of a list.

Example:

# Example for head
var lst=[1,2,3,4]
println head(lst)  # 1


[]new_list = insert(list,pos,item)

top

Returns a new_list with item inserted in list at position pos. (1-based)

Example:

# Example for insert
println insert([1,2,3],2,9)  # [1,9,2,3]


[]bigf_list = list_bigf(list)

top

Returns list as a list of big float containers. Invalid elements are discarded.


[]bigi_list = list_bigi(list)

top

Returns list as a list of big integer containers. Invalid elements are discarded.


[]bool = list_bool(int_or_string_list)

top

Returns int_or_string_list as a list of boolean values, with invalid items removed.


list = list_fill(list,value[,start,end])

top

sets all elements of a list to value. Big number types not yet supported.


[]float_list = list_float(int_or_string_list)

top

Returns int_or_string_list as a list of floats, with invalid items removed.


[]int_list = list_int(float_or_string_list)

top

Returns float_or_string_list as a list of integers. Invalid items will generate an error.


[]int64_list = list_int64(list)

top

Returns list as a list of 64-bit integers.


[]string_list = list_string(list)

top

Converts list to a list of strings.


number = max(list)

top

Calculate the maximum value in a list. Supports multi-dimensional arrays.

Example:

# Example for max
var lst=[1.2, 3, 2.3, 4]
println max(lst)  # 4


number = min(list)

top

Calculate the minimum value in a list. Supports multi-dimensional arrays.

Example:

# Example for min
println min([3,2,5])  # 2


item = peek(list_name)

top

Returns a copy of the last item in the list list_name. Returns an error if the list is empty.

Example:

# Example for peek
var lst=[1,2,3]
println peek("lst")  # 3


item = pop(list_name)

top

Removes and returns the last item in the named list list_name.

Example:

# Example for pop
var lst=[1,2,3]
var item=pop("lst")
println "Last item:",item


[]mixed = push_front([list,]item)

top

Adds item to the front of list. If only an item is provided, then a new list is started.

Example:

# Example for push_front
var lst=[1,2,3]
lst=push_front(lst,0)
println lst  # [0,1,2,3]


[]new_list = remove(list,pos)

top

Returns a new_list with the item at position pos removed. 1-based.

Example:

# Example for remove
println remove([1,2,3],2)  # [1,3]


list = scan_left(numeric_list,op_string,start_seed)

top

Creates a list from the intermediary values of processing op_string while iterating over list.

Example:

# Example for scan_left
println scan_left([1,2,3,4],"+",0)  # [1,3,6,10]


[]new_list = sort(list[,bool_reverse|map_options])

top

Sorts a list in ascending or descending (bool_reverse==true) order, or with map options.

[#SOL]Map options: .reverse (bool), .numeric (bool, .alphanumeric (bool)

Example:

# Example for sort
var l=[3,1,2]
println sort(l)  # [1,2,3]


[]any = ssort(list,field_name[,bool_reverse])

top

Sorts a list of structs, on a given field name, in ascending (true) or descending (false) order.


number|array = sum(list,axis,keepdims)

top

Calculate the sum of values. axis: -1/None=flatten, 0=first dim, 1=second dim. keepdims: preserve dimensions.

Example:

# Example for sum
println sum([1,2,3])  # 6


[]new_list = tail(list)

top

Returns a new list containing all items in list except the head item.

Example:

# Example for tail
println tail([1,2,3])  # [2,3]


[]new_list = uniq([]list)

top

Returns list sorted with duplicate values removed.

Example:

# Example for uniq
var lst=[1,2,2,3,3,3]
println uniq(lst)  # [1,2,3]


list = zip(list1,list2)

top

Creates a list by combining each element of list1 and list2.

Example:

# Example for zip
var a=[1,2]
var b=["a","b"]
println zip(a,b)  # [[1,"a"],[2,"b"]]