Skip to content

Commit

Permalink
Fix problems with negative powers and parentheses reported by Goeff.
Browse files Browse the repository at this point in the history
  • Loading branch information
dpvc committed Dec 5, 2014
1 parent 88dba53 commit 7da48e0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions macros/contextPermutation.pl
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ sub _contextPermutation_init {
$context->strings->clear();
$context->functions->disable("All");

$context->{pattern}{number} = '(?:^|(?<=[( ]))-?(?:\d+(?:\.\d*)?|\.\d+)(?:E[-+]?\d+)?',
$context->{pattern}{number} = '(?:(?:^|(?<=[( ^*]))-)?(?:\d+(?:\.\d*)?|\.\d+)(?:E[-+]?\d+)?',

$context->operators->add(
',' => {precedence => 0, associativity => 'left', type => 'bin', string => ',',
Expand Down Expand Up @@ -173,6 +173,7 @@ sub _contextPermutation_init {
$context->parens->set(
'(' => {close => ')', type => 'Cycle', formList => 0, removable => 0, emptyOK => 0, function => 1},
);
$context->flags->set(reduceConstants => 0);

$context->flags->set(
requireDisjoint => 0, # require disjoint cycles as answers?
Expand Down Expand Up @@ -526,7 +527,7 @@ package context::Permutation::BOP::power;
#
sub _check {
my $self = shift; my $equation = $self->{equation};
$equation->Error(["Powers of are not allowed"]) if $equation->{context}->flag("noPowers");
$equation->Error(["Powers are not allowed"]) if $equation->{context}->flag("noPowers");
$equation->Error(["You can only take powers of Cycles or Permutations"])
unless $self->{lop}->type eq "Cycle";
$self->{rop} = $self->{rop}{coords}[0] if $self->{rop}->type eq "Cycle" && $self->{rop}->length == 1;
Expand Down

0 comments on commit 7da48e0

Please sign in to comment.