From: Richard F. <fa...@gm...> - 2023-07-13 14:38:57
|
for what it is worth, using compile_file( filename) will produce a file filename.LISP which is the lisp version of the program in filename. It can be edited by hand for reasonableness... note that round() works for floats and bigfloats and rationals and CRE etc Here is your program, compiled. (in-package :maxima) (PROGN (DEFPROP $IS_AN_INT T TRANSLATED) (ADD2LNC '$IS_AN_INT $PROPS) (DEFMTRFUN ($IS_AN_INT $ANY MDEFINE NIL NIL) ($X) (DECLARE (SPECIAL $X)) ((LAMBDA ($K) (DECLARE (SPECIAL $K)) (LET (($PREDERROR T)) (COND ((AND ($NUMBERP $X) (IS-BOOLE-CHECK (MEQP $X (LET () (DECLARE (SPECIAL $K)) (IF (NOT (BOUNDP '$K)) (ADD2LNC '$K $VALUES)) (SETQ $K (SIMPLIFY (LIST '(%ROUND) $X))))))) $K)))) '$K) )) On Thu, Jul 13, 2023 at 7:04 AM Raymond Toy <toy...@gm...> wrote: > > On 7/13/23 02:35, Gunter Königsmann via Maxima-discuss wrote: > > The question might be where to draw the line between "this > fraction/integer/... plus all accumulated rounding errors from where that > float comes from" and "I actually mean exactly this float". Solve tries to > punt that decision to rat(). > > Would it instead make sense to try to tell float() what not to affect? > > That makes float() a lot more complicated. > > > > On 13 July 2023 10:43:38 CEST, David Billinghurst <dbm...@gm...> > <dbm...@gm...> wrote: > >> I am trying to fix bug #4156 <https://sourceforge.net/p/maxima/bugs/4156/> "generalized_lambert_w won't provide float solution" >> >> I need to test - in lisp - if a float or bfloat is an integer. The following maxima code does what I want. I haven't been able write a lisp version. I would expect the integer to be small - say |x| < 100 - and generated by the maxima float function from an integer input. >> >> I think I want to use the maxima equal function to handle bfloats. >> >> /* Convert float or bfloat x to integer if exact integer. nil otherwise */ >> is_an_int(x):= block([k], if numberp(x) and equal(x, k:round(x)) then k); >> >> (%i37) is_an_int(1); >> (%o37) 1 >> (%i38) is_an_int(1.0); >> (%o38) 1 >> (%i39) is_an_int(1.0b0); >> (%o39) 1 >> (%i40) is_an_int(1.5); >> (%o40) false >> ------------------------------ >> Maxima-discuss mailing lis...@li...https://lists.sourceforge.net/lists/listinfo/maxima-discuss >> >> > > _______________________________________________ > Maxima-discuss mailing lis...@li...https://lists.sourceforge.net/lists/listinfo/maxima-discuss > > _______________________________________________ > Maxima-discuss mailing list > Max...@li... > https://lists.sourceforge.net/lists/listinfo/maxima-discuss > |