… | |
… | |
1362 | my $self = shift; my $other = shift; my $ans = shift; |
1362 | my $self = shift; my $other = shift; my $ans = shift; |
1363 | return 1 if $self->type eq $other->type; |
1363 | return 1 if $self->type eq $other->type; |
1364 | my $typeMatch = ($self->createRandomPoints(1))[1]->[0]; |
1364 | my $typeMatch = ($self->createRandomPoints(1))[1]->[0]; |
1365 | $other = eval {($other->createRandomPoints(1))[1]->[0]} if Value::isFormula($other); |
1365 | $other = eval {($other->createRandomPoints(1))[1]->[0]} if Value::isFormula($other); |
1366 | return 1 unless defined($other); # can't really tell, so don't report type mismatch |
1366 | return 1 unless defined($other); # can't really tell, so don't report type mismatch |
|
|
1367 | return 1 if $typeMatch->class eq 'String' && Value::isFormula($ans->{typeMatch}); # avoid infinite loop |
1367 | $typeMatch->typeMatch($other,$ans); |
1368 | $typeMatch->typeMatch($other,$ans); |
1368 | } |
1369 | } |
1369 | |
1370 | |
1370 | # |
1371 | # |
1371 | # Handle removal of outermost parens in a list. |
1372 | # Handle removal of outermost parens in a list. |
… | |
… | |
1609 | next unless defined($f); |
1610 | next unless defined($f); |
1610 | unless (scalar(keys(%{$f->{variables}})) < 2) { |
1611 | unless (scalar(keys(%{$f->{variables}})) < 2) { |
1611 | warn "Only formulas with one variable can be graphed"; |
1612 | warn "Only formulas with one variable can be graphed"; |
1612 | return ""; |
1613 | return ""; |
1613 | } |
1614 | } |
|
|
1615 | unless ($f->typeRef->{length} == 1) { |
|
|
1616 | warn "Only real-valued functions can be graphed"; |
|
|
1617 | return ""; |
|
|
1618 | } |
1614 | if ($f->isConstant) { |
1619 | if ($f->isConstant) { |
1615 | $y = $f->eval; |
1620 | $y = $f->eval; |
1616 | $my = $y if $y < $my; $My = $y if $y > $My; |
1621 | $my = $y if $y < $my; $My = $y if $y > $My; |
1617 | } else { |
1622 | } else { |
1618 | my $F = $f->perlFunction; |
1623 | my $F = $f->perlFunction; |