Skip to content

Commit 788d788

Browse files
jhischwern
authored andcommitted
import Set-Scalar 1.24 from CPAN
git-cpan-module: Set-Scalar git-cpan-version: 1.24 git-cpan-authorid: JHI git-cpan-file: authors/id/J/JH/JHI/Set-Scalar-1.24.tar.gz
1 parent b1ce3ee commit 788d788

File tree

8 files changed

+90
-54
lines changed

8 files changed

+90
-54
lines changed

ChangeLog

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,24 @@
1+
2009-06-02 Jarkko Hietaniemi <jhi@iki.fi>
2+
3+
* Fixed "The intersection method does not like references in the
4+
set." [rt.cpan.org #46589], bug reported and fix provided by
5+
Father Chrysostomos.
6+
7+
* Cosmetics: removed trailing whitespace.
8+
9+
* Renamed README as README.old. It has been close to ten years.
10+
11+
* Added new README.
12+
13+
* Updated copyright years.
14+
15+
* Released as 1.24.
16+
117
2009-01-16 Jarkko Hietaniemi <jhi@iki.fi>
218

319
* Add overload for '@{}' as suggested by John Loverso,
420
meaning that you can now do @$set and get the members
5-
of the set (unordered, mind) [rt.cpan.org #42452]
21+
of the set (unordered, mind)
622

723
* Add overload for '=' (how did we manage so long without?)
824
[rt.cpan.org #42449]
@@ -39,7 +55,7 @@ Sat Aug 6 12:39:43 2005 Jarkko Hietaniemi <jhi@iki.fi>
3955

4056
* [cpan #13816] Set::Scalar blesses unblessed refs
4157

42-
A genuine bug, the suggsted fix used, but then again Set::Scalar
58+
A genuine bug, the suggested fix used, but then again Set::Scalar
4359
was never designed or tested be used with references as the set
4460
members. I would not recommend doing that unless much more
4561
testing has been conducted. A test added to misc.t for that,

MANIFEST

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ lib/Set/Scalar/Valued.pm
1010
lib/Set/Scalar/ValuedUniverse.pm
1111
lib/Set/Scalar/Virtual.pm
1212
README
13+
README.old
1314
t/basic.t
1415
t/basic_overload.t
1516
t/boolean.t

META.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
--- #YAML:1.0
22
name: Set-Scalar
3-
version: 1.23
3+
version: 1.24
44
abstract: ~
55
author:
66
- Jarkko Hietaniemi <jhi@iki.fi>
77
license: perl
88
distribution_type: module
99
configure_requires:
1010
ExtUtils::MakeMaker: 0
11+
build_requires:
12+
ExtUtils::MakeMaker: 0
1113
requires: {}
1214
no_index:
1315
directory:
1416
- t
1517
- inc
16-
generated_by: ExtUtils::MakeMaker version 6.48
18+
generated_by: ExtUtils::MakeMaker version 6.52
1719
meta-spec:
1820
url: http://module-build.sourceforge.net/META-spec-v1.4.html
1921
version: 1.4

README

Lines changed: 7 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,10 @@
1-
This is a long-waited-for (I hope) rewrite of the venerable Set::Scalar
2-
module. The original 0.00x series culminated in 0.003 back in May 1996,
3-
the 0.004 in October 1998 was just a minor update.
1+
The first priority of Set::Scalar is to be a convenient interface
2+
to sets (as in: unordered colletions of Perl scalars.) While not
3+
designed to be slow or big, neither has it been designed to be
4+
fast or compact.
45

5-
The most egregious problem with the old implementation was that having
6-
complex things such as objects as set members (for example if sets of sets
7-
were wanted) didn't really work.
8-
9-
While this new implementation is more correct, it may be also slower.
10-
Some operations are certainly slower, but some are faster. It all
11-
depends on your mix of operations.
12-
13-
Displaying sets is not as versatile as with the old implementation,
14-
but then on the other hand I doubt (hope) that anybody ever used the
15-
overly baroque interface anyway. If, however, I am wrong in this,
16-
please let me know, I'll think of something. The old interface should
17-
not be revived as such, I think, it was far too clunky.
18-
19-
The "valued sets" concept is now moved to its own subclass,
20-
Set::Scalar::Valued.
21-
22-
(There are two meta-classes, Set::Scalar::Universe and
23-
Set::Scalar::ValuedUniverse, but do not use them overmuch, as there
24-
are still some rough edges that may change in future releases.
25-
Do not use them directly (by instantiating them yourself, for example),
26-
$set->universe is about the only method that works and will continue
27-
to work. Even more internal-use-only are the Set::Scalar::Real and
28-
Set::Scalar::Virtual. Do not try to use them directly.
29-
Their interfaces are left undocumented on purpose.)
30-
31-
The "inverted sets" concept is history, removed, gone, not to return.
32-
You can just use -$set.
33-
34-
Let me know what you think, did I miss anything obvious? Any old
35-
functionality that I didn't purposefully/accidentally migrate to
36-
the new one? Could the documentation be better? (a rhetorical question)
37-
Any new functionality you would like to see? (Please don't say that
38-
you want the Cartesian product: it's a concept from wholly different
39-
world, the ordered sets. My sets are unordered.)
6+
Please see lib/Set/Scalar.pm for more information, once you have
7+
installed this module, "perldoc Set::Scalar" should work.
408

419
--
42-
Jarkko Hietaniemi <jhi@iki.fi>
43-
44-
10+
jhi@iki.fi

README.old

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
This is a long-waited-for (I hope) rewrite of the venerable Set::Scalar
2+
module. The original 0.00x series culminated in 0.003 back in May 1996,
3+
the 0.004 in October 1998 was just a minor update.
4+
5+
The most egregious problem with the old implementation was that having
6+
complex things such as objects as set members (for example if sets of sets
7+
were wanted) didn't really work.
8+
9+
While this new implementation is more correct, it may be also slower.
10+
Some operations are certainly slower, but some are faster. It all
11+
depends on your mix of operations.
12+
13+
Displaying sets is not as versatile as with the old implementation,
14+
but then on the other hand I doubt (hope) that anybody ever used the
15+
overly baroque interface anyway. If, however, I am wrong in this,
16+
please let me know, I'll think of something. The old interface should
17+
not be revived as such, I think, it was far too clunky.
18+
19+
The "valued sets" concept is now moved to its own subclass,
20+
Set::Scalar::Valued.
21+
22+
(There are two meta-classes, Set::Scalar::Universe and
23+
Set::Scalar::ValuedUniverse, but do not use them overmuch, as there
24+
are still some rough edges that may change in future releases.
25+
Do not use them directly (by instantiating them yourself, for example),
26+
$set->universe is about the only method that works and will continue
27+
to work. Even more internal-use-only are the Set::Scalar::Real and
28+
Set::Scalar::Virtual. Do not try to use them directly.
29+
Their interfaces are left undocumented on purpose.)
30+
31+
The "inverted sets" concept is history, removed, gone, not to return.
32+
You can just use -$set.
33+
34+
Let me know what you think, did I miss anything obvious? Any old
35+
functionality that I didn't purposefully/accidentally migrate to
36+
the new one? Could the documentation be better? (a rhetorical question)
37+
Any new functionality you would like to see? (Please don't say that
38+
you want the Cartesian product: it's a concept from wholly different
39+
world, the ordered sets. My sets are unordered.)
40+
41+
--
42+
Jarkko Hietaniemi <jhi@iki.fi>
43+
44+

lib/Set/Scalar.pm

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use strict;
55

66
use vars qw($VERSION @ISA);
77

8-
$VERSION = '1.23';
8+
$VERSION = '1.24';
99

1010
@ISA = qw(Set::Scalar::Real Set::Scalar::Null Set::Scalar::Base);
1111

@@ -57,7 +57,7 @@ Set::Scalar - basic set operations
5757
=head2 Creating
5858
5959
$s = Set::Scalar->new;
60-
$s = Set::Scalar->new(@members);
60+
$s = Set::Scalar->new(@members);
6161
6262
$t = $s->clone;
6363
$t = $s->copy; # Clone of clone.
@@ -106,6 +106,7 @@ Assuming a set C<$s>:
106106
107107
$s->is_null # Returns true if the set is empty.
108108
$s->is_empty # Alias for is_null.
109+
109110
$s->is_universal # Returns true if the set is universal.
110111
111112
$s->null # The null set.
@@ -121,7 +122,7 @@ Assuming a set C<$s>:
121122
$v = $s->unique($t);
122123
$c = $s->complement;
123124
124-
These methods have operator overloads:
125+
These methods have operator overloads:
125126
126127
$u = $s + $t; # union
127128
$i = $s * $t; # intersection
@@ -173,7 +174,7 @@ The C<compare> method returns a string from the following list:
173174
intersect", and in future (once I get around implementing it),
174175
"disjoint universes".
175176
176-
These methods have operator overloads:
177+
These methods have operator overloads:
177178
178179
$eq = $s == $t; # is_equal
179180
$dj = $s != $t; # is_disjoint
@@ -277,7 +278,7 @@ For example:
277278
278279
my $a = Set::Scalar->new(1..2);
279280
my $b = Set::Scalar->new(3..5);
280-
my $c = $a->cartesian_product($b); # As an object method.
281+
my $c = $a->cartesian_product($b); # As an object method.
281282
my $d = Set::Scalar->cartesian_product($a, $b); # As a class method.
282283
283284
The $c and $d will be of the same class as $a. The members of $c and
@@ -383,10 +384,10 @@ Jarkko Hietaniemi <jhi@iki.fi>
383384
384385
=head1 COPYRIGHT AND LICENSE
385386
386-
Copyright 2001,2002,2003,2004 by Jarkko Hietaniemi
387+
Copyright 2001,2002,2003,2004,2005,2007,2009 by Jarkko Hietaniemi
387388
388389
This library is free software; you can redistribute it and/or modify
389-
it under the same terms as Perl itself.
390+
it under the same terms as Perl itself.
390391
391392
=cut
392393

lib/Set/Scalar/Base.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ sub _intersection ($$) {
306306

307307
my %intersection = _make_elements $intersection->elements;
308308

309-
delete @intersection{ $that->elements };
309+
delete @intersection{ keys %{{ _make_elements $that->elements }} };
310310

311311
$intersection->delete( values %intersection );
312312

t/intersection.t

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use Set::Scalar;
22

3-
print "1..23\n";
3+
print "1..24\n";
44

55
my $a = Set::Scalar->new("a".."e");
66
my $b = Set::Scalar->new("c".."g");
@@ -95,6 +95,12 @@ print "ok 20\n";
9595
print "ok 23\n";
9696
}
9797

98+
print "not " unless join("", sort @{
99+
new Set::Scalar \$1,\$2,\$3,->intersection(
100+
new Set::Scalar \$2,\$3,\$4
101+
)
102+
}) eq join "", sort \$2,\$3;
103+
print "ok 24\n";
98104

99105

100106

0 commit comments

Comments
 (0)