ListTools - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Data Types : Tables, lists, and sets : ListTools Package : ListTools/Sorted

ListTools

  

Sorted

  

test if a list is sorted

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

Sorted(L, f, opts)

Parameters

L

-

list

f

-

(optional) procedure

opts

-

(optional) extra arguments to procedure f

Description

• 

The Sorted(L) function returns the value true if list L is sorted according to certain conditions; otherwise, false is returned.

  

If list L is a list of numeric values, then the elements of L are tested as to whether they are in ascending order.

  

If L is a list of strings or symbols, the elements of L are tested as to whether they are in lexicographical order.

  

Otherwise, Sorted(L) tests whether the elements in list L are in address order.

• 

If the optional argument f is specified as either `<` or `>`, the list must contain numeric values and the elements of the list are tested as to whether they are in ascending or descending order, respectively. Otherwise, the expression fx&comma;y&comma;opts is evaluated to determine whether element x precedes element y, where x and y are consecutive elements in list L.

Examples

withListTools&colon;

LWilliam&comma;Henry&comma;George&comma;Edward

L:=William&comma;Henry&comma;George&comma;Edward

(1)

SortedL

false

(2)

SortedsortL&comma;lexorder

true

(3)

L0.984&comma;0.733&comma;0.254&comma;0.305&comma;0.768&comma;0.992&comma;0.906&comma;0.537&comma;0.&comma;0.537&comma;0.906

L:=0.984&comma;0.733&comma;0.254&comma;0.305&comma;0.768&comma;0.992&comma;0.906&comma;0.537&comma;0.&comma;0.537&comma;0.906

(4)

SortedL

false

(5)

SortedsortL&comma;`>`

false

(6)

SortedsortL&comma;`>`&comma;`>`

true

(7)

Sortedseq&ExponentialE;i&comma;i&equals;10..10&comma;verify&comma;less_than

true

(8)

Sortedseqsini&comma;i&equals;10..10&comma;verify&comma;less_than

false

(9)

See Also

list

ListTools

map

type[list]

type[numeric]

type[string]

type[symbol]

 


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam