| kind | = | "Set" |
A set is an unordered collection of objects that contains no duplicates.
- +(otherSet)
- <<(value)
- ==(other)
- ===(other)
- ?&(...)
- ?|(...)
- each([indexOrArgOrCode] nil, [argOrCode] nil, [code] nil)
- empty?()
- hash()
- ifEmpty(...)
- include?(object)
- inspect()
- notice()
- remove!(value)
- seq()
- withIdentitySemantics!()
- ∈(element)
- ∉(element)
- ∩(otherSet)
- ∪(other)
- ⊂(otherSet)
- ⊃(otherSet)
- ⊆(otherSet)
- ⊇(otherSet)
returns a new set that contains the receivers elements and the elements of the set sent in as the argument.
Adds the argument to this set, if it's not already in the set. Returns the set after adding the object.
nil
[ show source ]
method(other,
if(self same?(
[]),
Reflector other:mimics?(cell(:other),
[]),
bind(rescue(Condition Error, fn(c, false)),
self include?(
other))))
if this set is non-empty, returns the result of evaluating the argument, otherwise returns the set
[ show source ]
macro(
argCount = call arguments length
cond(
argCount ==(
1),
theCode = call arguments [](
0)
unless(empty?,
call argAt(0),
self),
error!(Condition Error Invocation NoMatch, message: call message, context: call currentContext))
)
if this set is empty, returns the result of evaluating the argument, otherwise returns the set
[ show source ]
macro(
argCount = call arguments length
cond(
argCount ==(
1),
theCode = call arguments [](
0)
if(empty?,
call argAt(0),
self),
error!(Condition Error Invocation NoMatch, message: call message, context: call currentContext))
)
takes either one, two or three arguments. if one argument is given, it should be a message chain that will be sent to each object in the set. the result will be thrown away. if two arguments are given, the first is an unevaluated name that will be set to each of the values in the set in succession, and then the second argument will be evaluated in a scope with that argument in it. if three arguments is given, the first one is an unevaluated name that will be set to the index of each element, and the other two arguments are the name of the argument for the value, and the actual code. the code will evaluate in a lexical context, and if the argument name is available outside the context, it will be shadowed. the method will return the set. the iteration order is not defined.
if this set is empty, returns the result of evaluating the argument, otherwise returns the set
[ show source ]
macro(
argCount = call arguments length
cond(
argCount ==(
1),
theCode = call arguments [](
0)
if(empty?,
call argAt(0),
self),
error!(Condition Error Invocation NoMatch, message: call message, context: call currentContext))
)
Removes the argument from the set, if it's in the set. Returns the set after removing the object.
returns a new set that is the set-theoretic union of this set and the argument set
[ show source ]
method(other, self +(other))