On 02/10/2012 12:20 PM, Serge D. Mechveliani wrote:
On Fri, Feb 10, 2012 at 02:16:15PM +0400, Serge D. Mechveliani wrote:
People,
please, what is wrong in this Spad code?
---------------------------------------------------------------
)abbrev package PARSEI ParseInt
ParseInt() : with
parseInteger : String -> Integer
==
add
parseInteger(str : String) : Integer ==
base : Integer := 48
l : Integer := # str
s : Integer := 0
for i in 1 .. l repeat
(dNum := ord(elt(str, i)) - base; s := (10*s) + dNum)
s
---------------------------------------------------------------
?
It compiles and produces -> parseInteger "0"
46
Changing `base' to `b' improves it !!
It occurs that there are several Spad library operations/functions
called `base'. And _this_ `base' occurs to be 2 !
Nevertheless the program assigns base := 48.
Hence the compiler must accept that `base' is a local variable which
is assigned a value. A local thing must override the global library
export.
What might this all mean?
Well, you are a good detective!
https://github.com/hemmecke/fricas-svn/blob/master/src/algebra/si.spad.pamphlet#L36
base : () -> %
++ base() returns the base for the operations of
\spad{IntegerNumberSystem}.
It seems that FriCAS still has a problem with the difference between
constants and nullary functions. Since FriCAS is not functional, there
*is* a difference.
Ralf
--
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.