Since *read-default-float-format* is double-float (but this depends on lisp
implementation, it's true in GCL, not in Clozure CL ***),
it's possible to simply write
(mapcar #'cl:float '(1 2/3 .5))
But if the above depends on impementation, what about:
MAXIMA> (macroexpand '(float 1/3));
(LISP:FLOAT 1/3 1.0)
LISP package is found in GCL, not in CCL, and of course, 1.0 is also a
default float.
***) For some reason, *read-default-float-format* is double-float in
Maxima, but single-float in standalone GCL,
but anyway single-float = double-float = long-float in both, as seen with
(typep 1.0 'long-float)
(typep 1.0 'double-float)
(typep 1.0 'single-float)
So 1.0 1e0 1d0 1l0 are the same, and 1s0 is a short-float, smaller than the
others.
JCA
2013/1/31 Raymond Toy <toy.raymond at gmail.com>
> >>>>> "Edwin" == Edwin Woollett <woollett at charter.net> writes:
>
> Edwin> Paul Graham, Ansi Common Lisp, p. 144, has
> Edwin> an example of applying float to a lisp list using
> Edwin> mapcar, but it doesn't seem to work for me
> Edwin> using maxima in lisp mode:
> Edwin> -------------------------------------
> MAXIMA> (float 2/3)
>
> Edwin> 0.66666666666666663
> MAXIMA> (mapcar #'float '(1 2/3 .5))
>
> Edwin> Maxima encountered a Lisp error:
>
> Edwin> Error in FUNCTION [or a callee]: The function FLOAT is
> undefined.
>
> MAXIMA::FLOAT[1] is a macro. You probably want to say
>
> (mapcar #'cl:float '(1 2/3 .5))
>
> But note that this will convert rationals to single floats, not
> double. If you want doubles you can say
>
> (mapcar #'(lambda (x) (float x)) '(1 2/3 .5))
>
> (This works because it uses Maxima's FLOAT macro.)
>
> Having said that, I think we should probably make MAXIMA::FLOAT a
> function and either declare it inline or add a compiler-macro for it
> to expand into (cl::float x y).
>
> Ray
>
> Footnotes:
> [1] I think I added that long ago because there was lots of confusion
> in the code that expected (float x) to return a double, which is
> not what maxima wanted.
>
>
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>