Hi everyone, i'm new to Lisp, comming from other programming languages, so i'm still not getting along with the recursive aspect of lisp.
I need help with a function, i want to verify if a particular list of lists is valid. In this list of lists, the first element as a size of 3, and every element after grows in a proportion of 3*N, with N being the number of the element. as an example, if the list as 4 elements, the first will be size 3, the second 6, the third 9 and the fourth 12.
I know that to verufy this condition i need to use a recursive function, but until now i'm not being able to do it.
This function receives a list and returns a boolean, T or F, case the list being valid or not.
Can someone help me?
Thx in advance,
C. Ribeiro
New to lisp, help with function
Re: New to lisp, help with function
You absolutely do not need recursion to write this function. For instance you could do something like this:
Or mess around with the various MAP* functions and probably the EVERY function. Is there a good reason to use recursion for this that I'm not seeing?
Code: Select all
(defun multiple-of-three-lengths? (list)
(loop for el in list
for i from 1
always (= (length el) (* 3 i))))