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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!