ListTools - Maple Programming Help

Online Help

All Products    Maple    MapleSim


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

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:

Lseqi,i=1..12

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

(1)

fx,y→xymod4=0

f:=x,y→xymod4=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

L:=x21,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

 


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