NAME

Context("Partition") - Provides a context that allows the entry of a partition of an integer as a sum of positive integers.

DESCRIPTION

A partition is a sum of positive integers (usually that add up to a given number). Different partitions are ones that are made up of different integers in the sum. This context allows students to enter partitions, and provides the answer checker to determine if partitions are equal.

USAGE

loadMacros("contextPartition.pl");

Context("Partition");

$P1 = Compute("3 + 2 + 5");
$P2 = Partition(3,2,5);          # same as $P1

$P1->canonical;                  # produces "2 + 3 + 5"

$P3 = Compute("5 + 3 + 2");
$P4 = Compute("5 + 3 + 1 + 1");
$P3 == $P1;                      # true
$P3 == $P4;                      # false

$P3->sum;                        # returns 10