From: dpvc v. a. <we...@ma...> - 2005-08-13 21:33:09
|
Log Message: ----------- Allow a list of numbers to be converted to a set. Modified Files: -------------- pg/lib/Value: Set.pm Revision Data ------------- Index: Set.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value/Set.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -Llib/Value/Set.pm -Llib/Value/Set.pm -u -r1.7 -r1.8 --- lib/Value/Set.pm +++ lib/Value/Set.pm @@ -30,7 +30,8 @@ return $p if (Value::isFormula($p) && $p->type eq Value::class($self)); my $pclass = Value::class($p); my $isFormula = 0; my @d; @d = $p->dimensions if $pclass eq 'Matrix'; - if ($pclass =~ m/Point|Vector|Set/) {$p = $p->data} + if ($pclass eq 'List' && $p->typeRef->{entryType}{name} eq 'Number') {$p = $p->data} + elsif ($pclass =~ m/Point|Vector|Set/) {$p = $p->data} elsif ($pclass eq 'Matrix' && scalar(@d) == 1) {$p = [$p->value]} elsif ($pclass eq 'Matrix' && scalar(@d) == 2 && $d[0] == 1) {$p = ($p->value)[0]} elsif ($pclass eq 'Matrix' && scalar(@d) == 2 && $d[1] == 1) {$p = ($p->transpose->value)[0]} @@ -76,6 +77,8 @@ return $x if ref($x) eq $pkg; $x = Value::Interval::promote($x) if $x->canBeInUnion; return $x if $x->isSetOfReals; + return $pkg->new($x->value) + if $x->type eq 'List' && $x->typeRef->{entryType}{name} eq 'Number'; Value::Error("Can't convert %s to a Set",Value::showClass($x)); } |