Complete this function in Lisp to replace all numbers in a list with a given code, including sublists. (DEFUN HideNumbe

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Complete this function in Lisp to replace all numbers in a list with a given code, including sublists. (DEFUN HideNumbe

Post by answerhappygod »

Complete this function in Lisp to replace all numbers in a list with a given code, including sublists.

(DEFUN HideNumbers (L Code)
(COND ((NULL L) NIL)
; TBD -- Fill in this block
; Check for a number, an atom, otherwise recurse
)
)

(PRINT (HideNumbers '(1 2 SHOE (3 4 DOOR)) 'X)) returns (X X SHOE (X X DOOR))
(PRINT (HideNumbers '(((3)) (((ABC 5 6)))) 'X)) returns (((X)) (((ABC X X))))
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply