Categorize - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


ListTools

  

Categorize

  

categorize the elements of a list according to a given routine

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

Categorize(f, L, opts, ...)

Parameters

f

-

a reflexive procedure of two arguments

L

-

list

opts

-

(optional) options to procedure f

Description

• 

The Categorize( 'f', 'L', 'opts' ) function categorizes the list L into lists M1,M2, such that f(Mi[1], j, opts) returns true for each element j in the ith list Mi. The procedure f must return a value of type truefalse, and it must be reflexive: f(x, x, opts) must return true for each x in L.

• 

If f defines an equivalence relation, then the result is a partition of L into equivalence classes.

• 

If f can be written in the form (x,y) -> g(x) = g(y), then the call ListTools[Classify](g, L, opts) is more efficient, and equivalent except in the form of the output (Classify returns a table of sets).

Examples

withListTools:

Lseq1..12

L1,2,3,4,5,6,7,8,9,10,11,12

(1)

fx,yxymod4=0

fx,yxymod4=0

(2)

Categorizef,L

1,5,9,2,6,10,3,7,11,4,8,12

(3)

Lx21,x2+1,x1x+1,x22x+1,x12

Lx21,x2+1,x1x+1,x22x+1,x12

(4)

Categorizeverify,L,expand

x21,x1x+1,x2+1,x22x+1,x12

(5)

See Also

list

ListTools

ListTools[Classify]

seq

type/list

type/truefalse

verify/expand