[system] / trunk / pg / lib / Value / Set.pm Repository:
ViewVC logotype

Log of /trunk/pg/lib/Value/Set.pm

Parent Directory Parent Directory


Links to HEAD: (view) (download) (as text) (annotate)
Sticky Revision:

Revision 3716 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sun Oct 16 03:37:17 2005 UTC (14 years, 2 months ago) by dpvc
File length: 7145 byte(s)
Diff to previous 3525
In the past, when Value objects were inserted into strings, they would
automatically include parentheses so that if you had $f equal to 1+x
and $g equal to 1-x, then Formula("$f/$g") would mean (1+x)/(1-x)
rather than 1+(x/1)-x, which is what would happen as a straing string
substitution.

The problem is that this would also happen for real numbers, vectors,
and everything else, even when it wasn't necessary.  So if $x=Real(3),
then "Let x = $x" would be "Let x = (3)".

I have changed the behavior of the string concatenation for Value
objects so that parentheses are only added in a few cases: for
Formulas, Complex numbers, and Unions.  This makes the other Value
objects work more like regular variables in strings, but might cause
some problems with strings that are used as formulas.  For example, if
$a = Real(-3), then "x + 2 $a" will become "x + 2 -3", or "x-1" rather
than the expected "x - 6".  (The old approach would have made it "x +
2 (-3)" which would have worked properly).  For the most part, it is
easier to use something like "x + 2*$a" or even "x" + 2*$a in this
case, so the extra trouble of having to avoid parentheses when you
really meant to substitute the value into a string didn't seem worth
it.

Revision 3525 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sun Aug 14 00:23:10 2005 UTC (14 years, 4 months ago) by dpvc
File length: 7137 byte(s)
Diff to previous 3518
Added methods for testing containment of one set in another, and so
on.  These include:

     $A->contains($B)        Test if $B is a subset of $A (or an
                             element of $A if $B$ is a real number).

     $A->isSubsetOf($B)      Test if $A is a subset of $B.

     $A->isEmpty             True if $A is the empty set.

     $A->intersects($B)      True if $A and $B have numbers in common.

     $A->intersect($B)       The set of numbers common to both $A and $B.

Be careful of the difference between "intersect" and "intersects".
One is a set the other a true/false value.

Revision 3518 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sat Aug 13 21:34:50 2005 UTC (14 years, 4 months ago) by dpvc
File length: 6546 byte(s)
Diff to previous 3516
Allow a list of numbers to be converted to a set.

Revision 3516 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sat Aug 13 20:59:28 2005 UTC (14 years, 4 months ago) by dpvc
File length: 6353 byte(s)
Diff to previous 3508
Added isSetOfReals and canBeInUnion methods to the Value objects, and
replaced the ad hoc tests for these conditions to call these
routines.

Cleaned up the make() methods for Intervals, Sets and Unions, and
improved the new() methods to handle more cases better.

Fixed Value::makeValue() to handle an array reference correctly.

I don't THINK any of this will break anything.  :-)

Revision 3508 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sat Aug 13 16:58:56 2005 UTC (14 years, 4 months ago) by dpvc
File length: 6308 byte(s)
Diff to previous 3505
Added isReduced method to tell if a Union, Set or Interval is already
reduced.  Fixed up sort to use CORE::sort, and added sort and reduce
to Intervals, which do nothing, but are there for consistency.

Revision 3505 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sat Aug 13 16:33:50 2005 UTC (14 years, 4 months ago) by dpvc
File length: 6055 byte(s)
Diff to previous 3498
Added sort methods to Union and Set that return objects with their
data sorted.

Revision 3498 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sat Aug 13 00:35:11 2005 UTC (14 years, 4 months ago) by dpvc
File length: 6006 byte(s)
Diff to previous 3497
Fixed a typo in an error message.

Revision 3497 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sat Aug 13 00:25:27 2005 UTC (14 years, 4 months ago) by dpvc
File length: 6005 byte(s)
Diff to previous 3477
Added ability for Unions and Sets to simplify themselves
(automatically or on demand), and added flags to the Context and
answer checkers to control these features.  The new Context flags
are

    reduceUnions                tells whether unions are automatically
                                reduced when they are created.

    reduceUnionsForComparison   tells whether unions are reduced
                                before comparing them for equality
                                or inequality (etc) if they aren't
                                reduced already.

    reduceSets                  tells whether redundent elements are
                                removed from sets as they are created.

    reduceSetsForComparison     tells whether sets are reduced before
                                comparing them.

All of these default to true.

The Interval, Set, Union, and List answer checkers not have two new
flags for controlling these values:

    studentsMustReduceUnions    tells whether unions and sets will be
                                counted as incorrect when they are not
                                reduced to non-overlapping intervals
                                and at most one set with no repeated
                                entries.

    showUnionReduceWarnings     tells whether an error message will
                                be produced for non-reduced unions and
                                sets, or if they will be marked wrong
                                silently.  (Not available in Lists.)

Both of these are true by default, since most professors probably want
their students to write intervals in reduced form.  (Is this true?)
This corresponds the the current behavior of the interval checkers,
which require the student's answer to be the same set of intervals as
in the professor's, but with the addition of an error message when the
student answer is not reduced.

Revision 3477 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Thu Aug 11 20:57:18 2005 UTC (14 years, 4 months ago) by dpvc
File length: 5829 byte(s)
Diff to previous 3466
Added ability to subtract intervals, sets and unions.  Adjusted the
precedence of the union 'U' to be above _ and + so that things like
(1,5) U (7,10) - {8} U (2,3) will do ((1,5) U (7,10)) - ({8} U (2,3))
rather than the previous (1,5) U ((7,10) - {8}) U (2,3).  Finally,
added a constant 'R' to the Interval context that is equivalent to
(-inf,inf), so you can do things like R-{0} now.

Still need to work out reducing unions so that things like (1,3)U(2,4)
can become (1,4).

Revision 3466 - (view) (download) (as text) (annotate) - [select for diffs]
Added Thu Aug 11 14:19:26 2005 UTC (14 years, 4 months ago) by dpvc
File length: 4042 byte(s)
Added new Set object class to the Parser.  It implements a finite set
of real numbers, for use with unions and intervals.  E.g., (1,2) U {3}
or (1,2) U {3,4,5}.  You can created Set objects in your perl code via
the Set() command, e.g, Set(3,4,5) or Set("{1,2,3}").  You should set
the Context to Context("Interval") if you plan to use Set objects, as
this defined the braces to form sets (rather than using them as
parentheses, which is the default WW behavior).  Note that in Interval
context, you can NOT use braces as parentheses.

Current, Set objects are only allowed to be sets of numbers.  It would
be possible to extend that in the future.

This form allows you to request diffs between any two revisions of this file. For each of the two "sides" of the diff, enter a numeric revision.

  Diffs between and
  Type of Diff should be a

Sort log by:

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9