I am try to create a function with two arguments x and y
which creates a list of y times repeated elements X
but im getting confused on how to do it which or which method to use i think list compression can do but i want a shorter and simple method for example i want my simple code to be like this
if y = 4
and x = 7
result is list of elements (7, 7, 7, 7)
how can i go about it any ideas?? books links or anything that will give me a clue i tried searching but i have not been lucky
You can use make-list with the initial-element key:
CL-USER> (make-list 10 :initial-element 8)
(8 8 8 8 8 8 8 8 8 8)
While a good example of how you can code such a function by yourself is provided by Óscar answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With