Classify - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.
Our website is currently undergoing maintenance, which may result in occasional errors while browsing. We apologize for any inconvenience this may cause and are working swiftly to restore full functionality. Thank you for your patience.

Online Help

All Products    Maple    MapleSim


ListTools

  

Classify

  

classify the elements of a list, set, table, or rtable using a characteristic property

 

Calling Sequence

Parameters

Description

Examples

Compatibility

Calling Sequence

Classify(p, L, b1, ..., bn)

Parameters

p

-

characteristic property defining a class

L

-

list, set, table, or rtable; the object containing elements to be classified

b1, ..., bn

-

(optional) extra arguments passed to p

Description

• 

The Classify(p, L, b1, ..., bn) function groups the elements of L into sets according to the characteristic property p. That is, it returns a table T with indices i such that T[i] is the set of elements e of L having value p(e, b1, ..., bn) = i.

• 

If L is a table or rtable (such as an Array, Matrix, or Vector), the result is equivalent to applying this function to convert(L,list) with all other arguments the same.  (See convert/list.)

• 

The call Classify(p, L, b1, ..., bn) is mostly equivalent to ListTools[Categorize]((x, y) -> p(x)=p(y), L, b1, ..., bn) but more efficient. The form of the output is also different: Categorize returns a sequence of lists, while Classify returns a table of sets. On the other hand, Categorize is more general in that it accepts two-argument relations which can not necessarily be written in the form (x, y) -> p(x)=p(y) for some property p.

Examples

withListTools:

typesClassifywhattype,Hello,1,2.,π,x,x+y,exp,world!:

mapprint,opevaltypes:

string=Hello,world!

symbol=π,x

integer=1

procedure=exp

float=2.

`+`=x+y

(1)

number_of_distinct_prime_factorsnnopsifactorsn2:

npf30Classifynumber_of_distinct_prime_factors,`$`1..30:

indicesnpf30,nolist

0,1,2,3

(2)

npf300

1

(3)

npf301

2,3,4,5,7,8,9,11,13,16,17,19,23,25,27,29

(4)

npf302

6,10,12,14,15,18,20,21,22,24,26,28

(5)

npf303

30

(6)

Compatibility

• 

The ListTools[Classify] command was introduced in Maple 16.

• 

For more information on Maple 16 changes, see Updates in Maple 16.

See Also

Array

convert/list

list

ListTools

ListTools[Categorize]

Matrix

rtable

set

table

Vector