Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
moodle-qtype_stack
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elc
moodle-qtype_stack
Commits
856091b6
Commit
856091b6
authored
1 year ago
by
Chris Sangwin
Browse files
Options
Downloads
Patches
Plain Diff
Fix to issue #1060: add parentheses round neatives when displaying without multiplication signs.
parent
9d844cdd
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
stack/maxima/stackmaxima.mac
+6
-4
6 additions, 4 deletions
stack/maxima/stackmaxima.mac
tests/cassession2_test.php
+3
-1
3 additions, 1 deletion
tests/cassession2_test.php
with
9 additions
and
5 deletions
stack/maxima/stackmaxima.mac
+
6
−
4
View file @
856091b6
...
...
@@ -226,13 +226,15 @@ texput(multsgnonlyfornumberssym, "\\times")$
multsgnonlyfornumbers(e) := block([arglist, resstr, a, lastisnum, isnum, multsgn, str],
arglist: args(e),
a: pop(arglist),
resstr: if (atom(a) or is(length(args(a))=1) or safe_op(a) = "^") then tex1(a)
resstr: if (safe_op(a) = "-" or (real_numberp(a) and is(a<0))) then sconcat("\\left(", tex1(a), "\\right)")
else if (atom(a) or is(length(args(a))=1) or safe_op(a) = "^") then tex1(a)
else sconcat("\\left(", tex1(a), "\\right)"),
lastisnum: numberp(a),
for a in arglist do (
isnum: numberp(a),
multsgn: if (lastisnum and isnum) then tex1(multsgnonlyfornumberssym) else "\\,",
str: if (atom(a) or is(length(args(a))=1) or safe_op(a) = "^") then tex1(a)
str: if (safe_op(a) = "-" or (real_numberp(a) and is(a<0))) then sconcat("\\left(", tex1(a), "\\right)")
else if (atom(a) or is(length(args(a))=1) or safe_op(a) = "^") then tex1(a)
else sconcat("\\left(", tex1(a), "\\right)"),
resstr: sconcat(resstr, multsgn, " ", str),
lastisnum: isnum
...
...
This diff is collapsed.
Click to expand it.
tests/cassession2_test.php
+
3
−
1
View file @
856091b6
...
...
@@ -430,7 +430,7 @@ class cassession2_test extends qtype_stack_testcase {
public
function
test_multiplication_option_onum
()
{
$s1
=
[];
$cs
=
array
(
'a:2*x'
,
'b:2*3*x'
,
'c:3*5^2'
,
'd:3*x^2'
);
$cs
=
array
(
'a:2*x'
,
'b:2*3*x'
,
'c:3*5^2'
,
'd:3*x^2'
,
's1:x*(-y)'
,
's2:3*(-4)*x*(-y)'
);
foreach
(
$cs
as
$s
)
{
$s1
[]
=
stack_ast_container
::
make_from_student_source
(
$s
,
''
,
new
stack_cas_security
(),
array
());
}
...
...
@@ -445,6 +445,8 @@ class cassession2_test extends qtype_stack_testcase {
$this
->
assertEquals
(
'2\times 3\, x'
,
$s1
[
1
]
->
get_display
());
$this
->
assertEquals
(
'3\, 5^2'
,
$s1
[
2
]
->
get_display
());
$this
->
assertEquals
(
'3\, x^2'
,
$s1
[
3
]
->
get_display
());
$this
->
assertEquals
(
'x\, \left(-y\right)'
,
$s1
[
4
]
->
get_display
());
$this
->
assertEquals
(
'3\times \left(-4\right)\, x\, \left(-y\right)'
,
$s1
[
5
]
->
get_display
());
$s1
=
[];
$cs
=
array
(
'texput(multsgnonlyfornumberssym, "\\\\cdot")'
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment