Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Added descriptions of list functions 'find', 'unique' and 'vector'

...

Returns the number of elements in a list.

 

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.

 

list list( any,any,...)

Returns a list built from its arguments.

...

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

 

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.

...

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]]


list unique( list )

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

 

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.