## 5 Reputation

9 years, 303 days

## How to protect variables in a module...

Maple 18

Hello all of you,

I'm new here and I have a problem.

For homework I have to write a Maple package for the usage of dual quaternions. This is not a problem.

For example two functions of the package:

MyQuaternions := module()

export Pretty, Ugly:
local l1:
option package:

protect('i,j,k,epsilon'):

Pretty := proc(q::Vector)
description "":
return LinearAlgebra[Transpose](q)[1..4].Vector([1,i,j,k])+epsilon*(LinearAlgebra[Transpose](q)[5..8].Vector([1,i,j,k])):
end proc:

Ugly := proc(q)
description "":
local a;
a := Vector(8);
a[1]:=remove(has,remove(has,q,epsilon),{i,j,k});
a[2]:=coeff(remove(has,q,epsilon),i,1);
a[3]:=coeff(remove(has,q,epsilon),j,1);
a[4]:=coeff(remove(has,q,epsilon),k,1);
a[5]:=remove(has,coeff(q,epsilon),{i,j,k});
a[6]:=coeff(coeff(q,epsilon),i,1);
a[7]:=coeff(coeff(q,epsilon),j,1);
a[8]:=coeff(coeff(q,epsilon),k,1);
return a:
end proc:

end module:

savelib('MyQuaternions'):

Now I can load the module in a differnet maple worksheet "main.mw" by typing "with(MyQuaternions):"

The crucial thing now is the following: i,j,k,epsilon should be protected in "main.mw". I can do this by typing "protect('i,j,k,epsilon'):" Is there a way to tell maple to protect these variables automatically when the module is loaded? Or do I always have to type in the protect command by hand?

Thank you,

Josef

 Page 1 of 1
﻿