Bill Page wrote:
> On the other hand it is kind of disappointing that the following Spad
> code compiles without errors in both FriCAS and OpenAxiom:
>
> -- char.spad --
> )abbrev package CHARP CharPac
> CharPac: with
> char: Field -> NonNegativeInteger
> == add
> char(field:Field):NonNegativeInteger == characteristic()$field
> -- --
>
> but it does not work in either.
>
Why do you say it does not work? Currently in FriCAS interpreter it is
not possible to pass types as arguments to functions, but is Spad
code such arguments should work OK. Extending your example:
)abbrev package CHARPU UseCharPac
UseCharPac: with
useChar: Integer -> NonNegativeInteger
== add
import CharPac
useChar(i : Integer):NonNegativeInteger ==
i = 0 => char(AlgebraicNumber)
i = 1 => char(PrimeField(7))
error "i must be 0 or 1"
-----
I get the expected result:
(1) -> useChar(0)
(1) 0
Type:
NonNegativeInteger
(2) -> useChar(1)
(2) 7
Type:
PositiveInteger
--
Waldek Hebisch
[email protected]
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---