Question
LISP (clisp.cons.org) write a recursive double-odd, MY-DOUBLE-ODD that doubles the odd values and leaves ;; the even values alone ;; ex. (MY-DOUBLE-ODD (1 2 3
LISP (clisp.cons.org)
write a recursive double-odd, MY-DOUBLE-ODD that doubles the odd values and leaves ;; the even values alone ;; ex. (MY-DOUBLE-ODD (1 2 3 4 5 6)) returns => (2 2 6 4 10 6) ;;
I'm unsure as to why this code isn't working.
[1]> (defun MY-DOUBLE-ODD (n1 n2 n3 n4 n5 n6) (if (oddp n1) (setq n1 (* n1 2))) (if (oddp n2) (setq n2 (* n2 2))) (if (oddp n3) (setq n3 (* n3 2))) (if (oddp n4) (setq n4 (* n4 2))) (if (oddp n5) (setq n5 (* n5 2))) (if (oddp n6) (setq n6 (* n6 2))) (printem n1 n2 n3 n4 n5 n6) ) MY-DOUBLE-ODD [2]> (MY-DOUBLE-ODD '(1 2 3 4 5 6))
*** - EVAL/APPLY: Too few arguments (1 instead of at least 6) given to MY-DOUBLE-ODD The following restarts are available: ABORT :R1 Abort main loop Break 1 [3]>
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started