CL float with mapcar?



(mapcar #'$float '(1 2/3 0.5))
works fine in lisp.  Note the presence of $ there.

I think that you should really be doing (mapcar #'(lambda(r)(coerce r 
'double-float))   '( 1 2/3 0.5))

if that is what you want.  I'm not sure that (float *)  is in the ANSI 
standard.


RJF

On 1/30/2013 4:02 PM, Raymond Toy wrote:
>>>>>> "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