I wanted to create a function that verify if the numbers of a list fall between the range of 1 and 10. If they do, I wanted to add it to a new list that I created. However, if they fail to fall within the range I decided to convert them so they fit in rather than discarding them (by adding (1+ (random 10)).
The appearance of my function is as follow:
(defun fitrange (lst)
"(lst) check every number if it fits the range (1-10)"
(do ((fit lst (cdr fit))
(top nil (and (>= fit 1) (=< fit 10)) (cons fit top))
(or (< fit 1) (> fit 10))
(cons (+ fit (1+ (random 10))) top))))
When I run the function, it indicates error where fit is an unbound variable.
Any insight would be helpful, because any changes I tried turned into failure.
I'm fairly new to Lisp and the manual helped yet left me confused as well...
Thank you in advance. I appreciate it.