Lisp - convert numbers to evens
Lisp - convert numbers to evens
(OP)
Hi,
Can anyone tell me how to convert odd numbers in to even numbers in LISP?
I have a lisp routine which returns both even and odd numbers (0,1,2,3 up to 9) and I need to return and function that will round the figure down to the nearest even number, e.g.: 1 to 0, 3 to 2 etc.
Can anyone help?
Thanks in advance for any help
Dan
Can anyone tell me how to convert odd numbers in to even numbers in LISP?
I have a lisp routine which returns both even and odd numbers (0,1,2,3 up to 9) and I need to return and function that will round the figure down to the nearest even number, e.g.: 1 to 0, 3 to 2 etc.
Can anyone help?
Thanks in advance for any help
Dan





RE: Lisp - convert numbers to evens
"Whether you think that you can, or that you can't, you are usually right "
.. Henry Ford
RE: Lisp - convert numbers to evens
I am getting an error:
; error: bad argument type: numberp:
I have been tring it as follows,
(XSTR (fix (/ XSTR 2)) 2)
I am tring to overwrite "XSTR" which is either odd or even, with a new "XSTR" value which is only even.
Can you tell me where I am going wrong.
RE: Lisp - convert numbers to evens
"Whether you think that you can, or that you can't, you are usually right "
.. Henry Ford
RE: Lisp - convert numbers to evens
Try this..
(setq XSTR (atof XSTR))
(setq XSTR (*(fix(/ XSTR 2))2))
"Whether you think that you can, or that you can't, you are usually right "
.. Henry Ford
RE: Lisp - convert numbers to evens
It know works, it was a string!
Thanks for the help.
Dan