Gabriel Dos Reis <[email protected]> writes:
| The algebra is full of examples where things work by a sheer amount of
| luck. Consider the function rightPower in functor MonadWithUnit:
|
| rightPower(a: %,n: NonNegativeInteger) ==
| zero? n => 1
| res := 1
| for i in 1..n repeat res := res * a
| res
|
| What should be the type of constant 1 selected at the assignment
|
| res := 1
|
| and why?
Another example: Consider the function leftLcm from
NonCommutativeOperatorDivision(P,F) where
P: MonogenicLinearOperator(F)
F: Field
the function definition is:
leftLcm(a,b) ==
a = 0 =>b
b = 0 =>a
b0 := b
u := monomial(1,0)$P
v := 0
while leadingCoefficient b ~= 0 repeat
qr := leftDivide(a,b)
(a, b) := (b, qr.remainder)
(u, v) := (u*qr.quotient+v, u)
b0*u
The problem is the definition of the local variable v:
v := 0
There are four candidates in scope:
0: P
0: F
0: NonNegativeInteger
0: Integer
(the right answer is 0@P).
-- Gaby
--
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/fricas-devel?hl=en.