Versions Compared

Key

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

...

a = nil                   # version 2
for i = 1 to count(b) do  # version 2
    a = a & [sin(b[i])]   # version 2
end for                   # version 2

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.


number

...

count(

...

list

...

)

Returns the number of elements in a list.

 

list

...

list(

...

any,any,...)

Returns a list built from its arguments.

 

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 :

...

function

...

compare(a,b)

...


   

...

return

...

a

...

<

...

b

...


...

end

...

compare

...

 

...

numbers

...

=

...

[1,5,3,9,0,4,6,7,8,2]

...


...

print

...

(sort(numbers,

...

">"))

...

       #

...

prints

...

in

...

decreasing

...

order

...


...

print

...

(sort(numbers,

...

"compare"))

...

#

...

prints

...

in

...

ascending

...

order

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 )

...