I am learning little Fricas. But confused about this
(21) -> g2(x: Integer): Integer == x^2
Function declaration g2 : Integer -> Integer has been added to
workspace.
Is the above function supposed to accept only Integer type as input and
return Integer? Then why does this call work:
22) -> g2(7.0)
Compiling function g2 with type Integer -> Integer
(22) 49
Type:
PositiveInteger
It seems to have casted 7.0 to 7? And should not the type returned be
Integer and not PositiveInteger?
23) -> typeOf(7.0)
(23) Float
Fricas does however catch the error when passing string:
24) -> g2("hello")
Conversion failed in the compiled user function g2 .
Cannot convert the value from type String to Integer .
Compare to Maple
-------------------------------------------------
g2:=proc(x::integer)::integer;
x^2;
end proc;
g2(7.0);
Error, invalid input: g2 expects its 1st argument, x, to be of type
integer, but received 7.0
-----------------------------------------------
And that is what I was expecting, given that Fricas is very strongly typed.
Did I do something wrong or do I need to turn some setting on or something?
Fricas 1.3.9
Thanks
--Nasser
--
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/fricas-devel/f91e9438-5e07-4e2b-a9b8-4f320bd97c2cn%40googlegroups.com.