classify the elements of a list, set, table, or rtable using a characteristic property
Classify(p, L, b1, ..., bn)
characteristic property defining a class
list, set, table, or rtable; the object containing elements to be classified
b1, ..., bn
(optional) extra arguments passed to p
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.
types ≔ Classify⁡whattype,Hello,1,2.,Pi,x,x+y,exp,world!:
number_of_distinct_prime_factors ≔ n→nops⁡ifactors⁡n2:
npf30 ≔ Classify⁡number_of_distinct_prime_factors,`$`⁡1..30:
The ListTools[Classify] command was introduced in Maple 16.
For more information on Maple 16 changes, see Updates in Maple 16.
Download Help Document
What kind of issue would you like to report? (Optional)