Calling a function n times acl2

241 Views Asked by At

I cannot figure out how to call a function n times to be used in another function

I have a function

(defun right-shift (l)
   (append l '(0))) 

And I need to write another function that needs to shift '(l) n times

(defun right-shift-n-times (l n)
   (natp n)
       ...)

I am not even sure I started that function right and I cannot figure out how to call it n times.

1

There are 1 best solutions below

2
Martin Buchmann On

You should given some more background of your problem. If you want to shift bit-wise data there are way more efficient ways, I guess.

For a homework-style solution, I would start with something like this:

 (defun right-shift-n-times (l n)
       (if (zerop n)
           l
           (right-shift-n-times (right-shift l) (1- n))))

but I am not a very experienced lisper.