CL float with mapcar?



>>>>> "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.