Rick , you're right, I don't need a subclass really. By doing the
intersection the other way around I get what I want:
dir1 =.directory~new~~put('Rick','First')~~put('McGuire','Last')
........................................... rexxtry.rex on WindowsNT
set1 = .set~of('First','Last')
........................................... rexxtry.rex on WindowsNT
say set1~intersection(dir1)~makeArray~makeString
........................................... rexxtry.rex on WindowsNT
say dir1~intersection(set1)~makeArray~makeString
First
Last
or alternativily using .table instead of .set:
dir1 =.directory~new~~put('Rick','First')~~put('McGuire','Last')
........................................... rexxtry.rex on WindowsNT
tab1 = .table~new~~put('First','First')~~put('Last','Last')
........................................... rexxtry.rex on WindowsNT
say tab1~intersection(dir1)~makeArray~makeString
First
Last
........................................... rexxtry.rex on WindowsNT
say dir1~intersection(tab1)~makeArray~makeString
First
Last
My confusion stems from a number of points:
1. "Usually" Intersection ought to be associative: "a~intersection(b)"
equals "b~intersection(a)"
2. The description of the Set class in 5.3.14 states with respect to
items(values) and indexes:
A Set is a collection containing member items where the index is the
same as the item (similar to a Bag
collection).
3. The description for intersection in 5.3.14.4, which is specific for
the Set class specifies that the indexes must be in both collections:
Returns a new collection (of the same class as the receiver) containing
only those items from the receiver
whose indexes are in both the receiver collection and the argument
collection.
4. When I accidentally tried:
set2 = .set~new~~put('Rick','First')
Oooops ! ... try again. Incorrect call to method
The index and value objects must be the
same for PUT to an index-only collection
the error message mentions an index-only collection.
Therefore my "misunderstanding", not heaving read section 3.14.9, that
more or less contradicts all of the above and makes a special case of
the Set class, a subclass of .Table which is a .MapCollection.
There must be a reason why .Set is treated differently, right?
Ruurd
On 21-8-2013 1:18, Rick McGuire wrote:
What are you actually trying to achieve? I suspect a subclass might
not be required.
Rick
On Tue, Aug 20, 2013 at 7:15 PM, Ruurd Idenburg <ru...@idenburg.net
<mailto:ru...@idenburg.net>> wrote:
Ok, I see I'm referring to the receiver as a MapCollection, which
a set ain't and for Set the items in the argument collection are used.
Gotta subclass .set then to get what I want.
Ruurd
On 21-8-2013 1:00, Ruurd Idenburg wrote:
Thanks Rick, but from .directory upwards the inheritance chain
isn't it:
.directory -> .MapCollection -> .Collection
So what about this in section 5.3.19:
If argument is a MapCollection, then index values are used to
determine membership, and items are
inserted into the result using the index and item pairs.
Ruurd
On 21-8-2013 0:46, Rick McGuire wrote:
What you are missing is the act of coercing the source
collection into a compatible type (this is described in section
5.3.19 The Concept of Set Operations). In this situation, the
items are used to integration with the set. If you wish to
merge the indexes, then source~allindexes as an argument for the
merge.
Rick
On Tue, Aug 20, 2013 at 5:19 PM, Ruurd Idenburg
<ru...@idenburg.net <mailto:ru...@idenburg.net>> wrote:
This is the description of set~intersection:
5.3.14.4. intersection
>>-intersection(argument)--------------------------------------><
Returns a new collection (of the same class as the receiver)
containing only those items from the receiver
whoseindexes are in both the receiver collection and the
argument collection. The argument can be any
collection class object. The argument must also allow all of
the index values in the receiver collection.
and I think this is the code for set~intersection in
CoreClasses.orx:
::METHOD intersection -- take the
intersection of sets
use strict arg other -- get the companion
object
signal on nomethod
new = self~class~new -- use a new instance
if other~isA(.Collection) then
values = other~allitems -- get all of the items from the
other collection
else
values = other~makearray -- ask for an array
version of the source
count = values~items
do i = 1 to count
index = values[i]
-- if we have one of these, put into the result
-- NB: Since this is a SET, there will only be one copy
accumulated.
if self~hasindex(index) then
new~put(index)
end
return new -- return the
difference collection
nomethod: -- unknown method sent
raise syntax 93.948 array(1, "Collection")
In my case the other collection is a .directory, where items
and indexes are not necessarily the same.
What am I misunderstanding?
-- Ruurd Idenburg
------------------------------------------------------------------------------
Introducing Performance Central, a new site from SourceForge and
AppDynamics. Performance Central is your source for news,
insights,
analysis and resources for efficient Application Performance
Management.
Visit us today!
http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
_______________________________________________
Oorexx-users mailing list
Oorexx-users@lists.sourceforge.net
<mailto:Oorexx-users@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/oorexx-users
------------------------------------------------------------------------------
Introducing Performance Central, a new site from SourceForge and
AppDynamics. Performance Central is your source for news, insights,
analysis and resources for efficient Application Performance Management.
Visit us today!
http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
_______________________________________________
Oorexx-users mailing list
Oorexx-users@lists.sourceforge.net
<mailto:Oorexx-users@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/oorexx-users
--
Ruurd Idenburg
------------------------------------------------------------------------------
Introducing Performance Central, a new site from SourceForge and
AppDynamics. Performance Central is your source for news, insights,
analysis and resources for efficient Application Performance Management.
Visit us today!
http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
_______________________________________________
Oorexx-users mailing list
Oorexx-users@lists.sourceforge.net
<mailto:Oorexx-users@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/oorexx-users
--
Ruurd Idenburg
------------------------------------------------------------------------------
Introducing Performance Central, a new site from SourceForge and
AppDynamics. Performance Central is your source for news, insights,
analysis and resources for efficient Application Performance
Management.
Visit us today!
http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
_______________________________________________
Oorexx-users mailing list
Oorexx-users@lists.sourceforge.net
<mailto:Oorexx-users@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/oorexx-users
------------------------------------------------------------------------------
Introducing Performance Central, a new site from SourceForge and
AppDynamics. Performance Central is your source for news, insights,
analysis and resources for efficient Application Performance Management.
Visit us today!
http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
_______________________________________________
Oorexx-users mailing list
Oorexx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-users
--
Ruurd Idenburg
------------------------------------------------------------------------------
Introducing Performance Central, a new site from SourceForge and
AppDynamics. Performance Central is your source for news, insights,
analysis and resources for efficient Application Performance Management.
Visit us today!
http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
_______________________________________________
Oorexx-users mailing list
Oorexx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-users