Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

+ Addition

- Subtraction

* Multiplication

/ Division

^ Power

 




The boolean operators are :

...

Operations between lists and numbers. op is any of the operations defined above.

 


list ( list and list )
list ( list or list )
list ( not list )

Conjunction, Disjunction and Negation.

...


list ( list and number ) list ( number or list )

...

# copies elements 1, 5, 9, 13, 17 of x into y
Y = X[1,20,4]

 


list list[vector]

Extract a selection of elements from a list. The vector supplied as the argument provides the set of indices to be used. For example:   

...

Tests whether a value is in a list or not. Returns a 0 (false) or 1 (true)

 


list ( list & list )

Concatenate two lists. Note that to add a single element to a list, it must first be converted into a single-element list, for example:

mylist = mylist & [23]

 


list abs( list )
list acos( list )
list asin( list )
list atan( list )
list cos( list )
list exp( list )
list int( list )
list log( list )
list log10( list )
list neg( list )
list sgn( list )
list sin( list )
list sqrt( list )
list tan( list )
list div( list,list )
list max( list,list )
list min( list,list )
list max( list,number )
list min( list,number )
list mod( list,list )

...

This shows that the types of the elements in the input lists are not restricted – a list can contain many different data types (e.g. [number, vector, geopoints]) and as long as the requested function is valid for each type, the correct result will be returned. If the requested operation is illegal for that element (e.g. sin(['hello'])) then it will fail on that element. See the descriptions of these functions for the relevant data types.


Anchor
count
count

number count( list )

Returns the number of elements in a list.


Anchor

...

find
find

number or list find( list,any )
number or list find( list,any,string )

Searches the given list for an item and returns the index of the first occurrence of it. If an optional third argument is given as the string 'all', then a list of the indexes of all occurrences of the item is returned. In both cases, if the item is not contained in the list, nil is returned.


Anchor

...

list
list

list list( any,any,...)

Returns a list built from its arguments.

...


Anchor
sort
sort

list sort( list )

Sorts a list in ascending order.

...


list sort( list,string )

Sorts a list given a comparison, expressed as a string : Ascending "<", descending ">"; you may specify the sorting criterium in a comparison function :

...

Note that it is not valid to sort a list which contains more than one type of data element.

...


Anchor
sort_indices
sort_indices

list sort_indices( list )
list sort_indices( list,string )

Sorts a list and returns the sorted indices. The default behaviour is to sort in ascending order unless an alternative comparison function is provided. See example under sort_and_indices() to see how this function works.

...


Anchor
sort_and_indices
sort_and_indices

list sort_and_indices( list)
list sort_and_indices( list,string )

...

Original list    : [10,12,9,7,6]
Sorted list      : [6,7,9,10,12]
Sorted indices   : [5,4,3,1,2]
Sort and indices : [[6,5],[7,4],[9,3],[10,1],[12,2]]


Anchor
unique
unique

list unique( list )

Returns a list of the unique elements in the input list.

...


Anchor
vector
vector

vector vector( list )

Returns a vector containing the numeric elements of the input list. Any nil list elements are converted to vector_missing_value. Any other non-numeric elements will cause an error. If the input list is empty, the function returns nil.

...