Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LimitedFraction with new extension #1192

Open
pstaabp opened this issue Feb 11, 2025 · 2 comments
Open

LimitedFraction with new extension #1192

pstaabp opened this issue Feb 11, 2025 · 2 comments

Comments

@pstaabp
Copy link
Member

pstaabp commented Feb 11, 2025

I've been writing/rewriting some problems to take advantage of the new extensions. Here's a nice example with Point and Fraction and I will update the samples problems to include something like this.

DOCUMENT();
loadMacros('PGstandard.pl', 'PGML.pl', 'contextFraction.pl', 'PGcourse.pl');

Context(context::Fraction::extending("Point"));
$A = non_zero_random(-20,20);
$B = non_zero_random(-20,20);
$C = non_zero_random(-20,20);

$xint = Point(Fraction($C,$A),0);
$yint = Point(0,Fraction($C,$B));

BEGIN_PGML
Find the [`x`]-intercept and [`y`]-intercept of the line: [` [$A]x+[$B]y=[$C] `]

a) [`x`]-intercept: [_]{$xint}

b) [`y`]-intercept: [_]{$yint}
END_PGML

ENDDOCUMENT();

@dpvc Is there a way to include the LimitedFraction with the Point context? I couldn't quite determine this.

@dpvc
Copy link
Member

dpvc commented Feb 11, 2025

Is there a way to include the LimitedFraction with the Point context?

Well, the LimitedFraction context is an extension of the LimitedNumeric context, and since neither the Point nor the LimitedNumeric contexts are based on the extension idea, they can't really be mixed.

On the other hand, if you add the ( and , definitions into the LimitedFraction context, that will allow you to create points, so may be what you are looking for. Perhaps contexts like Point, Vector, and Matrix should be extensions as well, so they can be added onto any context (like Point extending Complex for complex points), so that you could use Point to extend LimitedFraction (which would really be Point extending Fraction extending LimitedNumeric).

In any case, you could use

loadMacros('PGstandard.pl', 'PGML.pl', 'contextFraction.pl', 'PGcourse.pl');
Context('LimitedFraction);
Context()->operators->redefine(',');
Context()->parens->redefined('(');
Context()->parens->set('(' => { formMatrix => 0 });

This redefines the usual comma and parentheses, restricting points to not form matrices when nested (it will produce an error instead).

See if that does what you need.

@pstaabp
Copy link
Member Author

pstaabp commented Feb 12, 2025

I'll take a look at this, but this may be a candidate for adding the extension. I may take a look at doing the extension. This would make it much easier for authors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants