This is supposed to be a definition of a function which returns t if the entered value is an even natural number and returns nil if the entered value is an odd natural number:
(defun evec (n)
(if (zp n)
(if (zerop n)
t
nil)
(evec (- n 2))))
It correctly returns t when I enter an even number and It's supposed to return nil literally for anything else but it doesn't! Actually I guess it does not halt and I don't understand why. When I enter a number like -1 which is obviously not an even natural number, I expect from this code to go through first 'if' because (zp -1) equals t and since -1 is not equal to 0 then (zerop -1) should be nil which means that the output should be nil and the program should terminate.
In fact I know how to implement this function better in way that it actually work and all I need to know is why this code doesn't work, in order to understand this language better because I've just started learning ACL2!...
Thank you for your consideration.