van.nek at arcor.de
Tue May 29 04:01:40 CDT 2007
Am 25 May 2007 um 18:15 hat Stavros Macrakis geschrieben:
I was off for some days, so here my late answer.
> Speaking of misleading names, contrib/stringproc has a routine called parsetoken which reads an
> integer or float from a string (using the Lisp reader, as it happens), e.g.
Maybe 'parsenumber´ would be better, maybe 'parsetoken´ is appropriate, because it
tokenizes the 2 from 2 / 3, just as a warning.
> parsetoken("2.3") => 2.3
> parsetoken("2/3") => 2/3 (I just fixed this case; previously it returned a CL rational)
thanks for fixing this. Maybe I have overseen this, because e.g.
2*parsetoken("1/3") => 2/3
which is correct,
but of course not a Maxima rational.
> Useful functionality. But, as its documentation says, it only works on numbers, not tokens in
> parsetoken("foo") => false
> parsetoken("*") => false
which is intended
> And not all Maxima numbers:
> parsetoken("2.3b0") => false
I have just committed a new version, which can parse bigfloats using the Maxima-reader
(mread). Integers, floats and rationals are still parsed first only by the Lisp-reader (read),
so that the speed advantage still remains.
(%i1) s: "12 1.2 .12e+3 .12b-1 1/2 sqrt(2) %e foo"$
(%i2) ss: split(s);
(%o2) [12, 1.2, .12e+3, .12b-1, 1/2, sqrt(2), %e, foo]
(%o3) [12, 1.2, 120.0, 1.2b-2, -, false, false, false]
More information about the Maxima