Question
Using Common LISP , write a recursive function (REPLICATE L NLIST) which takes a list L and a list NLIST of integers (all of which
Using Common LISP, write a recursive function (REPLICATE L NLIST) which takes a list L and a list NLIST of integers (all of which can be assumed to be >= 0) and which uses NLIST as a "template" to produce a new list in whch each element of L is replicated the number of times specified in NLIST.
For example:
(REPLICATE '(A B C D E) '(1 0 4 3 2)) should return (A C C C C D D D E E),
(REPLICATE '(W X Y Z X Q W) '(3 4 0 1) should return (W W W X X X X Z),
(REPLICATE '(1 2 3 1) '(1 2 3 4 5 6)) should return (1 2 2 3 3 3 1 1 1 1),
(REPLICATE '(X W X E D R) nil) should return nil,
(REPLICATE nil '(1 0 0 3 2)) should return nil.
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