in - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Operations : Sets and lists : in

in

membership operator for sets or lists

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

element in objs

element∈objs

element in SetOf( type )

element∈SetOftype

Parameters

element

-

expression

objs

-

set or list

type

-

valid type expression

Description

• 

The in operator tests for set or list membership.  The given container, objs, is searched for element. Evaluating an in expression in a boolean context, or via evalb, returns true if element is in objs, it returns false if element is not in objs.  If the input contains symbolic components and the answer cannot be determined, a symbolic answer is returned. The default evaluator always returns in expressions unevaluated.

• 

You can enter the command in using either the 1-D or 2-D calling sequence. For example, 1 in {1,2,3,4} is equivalent to 1∈1,2,3,4.

• 

When using the SetOf abstract set constructor, sets can be constructed from types.  For example, the set of all integers can be created using SetOf( integer ).  The SetOf constructor takes only one argument.  More complex sets can be constructed using union, intersect and minus.

• 

If obj is a complex expression involving union, intersect or minus, it may be more efficient to pass obj as an unevaluated expression.  Using an unevaluated expression allows in to use its own rules for set membership across these functions.

• 

The assume facility accepts the in operator.

Examples

1∈1,2,3,4

1∈1,2,3,4

(1)

evalb

true

(2)

1∈SetOfinteger

1∈SetOfinteger

(3)

evalb

true

(4)

1∈SetOfpolynom∖SetOfinteger

1∈SetOfpolynom∖SetOfinteger

(5)

evalb

false

(6)

1∈A∪B∪C∖D

1∈unionA,B,C∖D

(7)

evalb

1∈Aor1∈Bor1∈Candnot1∈D

(8)

1∈1,2,3∩1,2,6∖1,4,7

1∈2

(9)

evalb

false

(10)

evalb1∈'1,2,3∩1,2,6∖1,4,7'

false

(11)

isx∈SetOfrealassumingx::fraction

true

(12)

isx∈SetOfintegerassumingx::rational

false

(13)

coulditbex∈SetOfintegerassumingx::rational

true

(14)

assumex∈SetOfreal;aboutx

Originally x, renamed x~:
  is assumed to be: real

The command in also works with lists.

evalb1∈6,7,1,8

true

(15)

sopsolvea+b=5,b2a2=25,a,b

s:=a=0,b=5

(16)

evalb'a=0'∈s

true

(17)

See Also

add

assume

do

intersect

list

minus

mul

seq

set

type

uneval

union

 


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