I am trying to iterate through the list and make an if statement to each of the elements I encounter in CLISP
Most of my problems come from me not knowing the syntax very well though
Here is what I am trying to do:
*"lst"*
is for example (1 4 2 6 4 7 2 4)
(setq finalList())
(loop for x in lst
(if ((< x 5) && (not(equal(x nil)))) ; IF x < 5 and x != nil
(append lst x) ; THEN STATEMENT
(princ "Skip") ; ELSE STATMENT
)
That logically should have done it, however, I am possibly wrong with my syntax (If I forgot extra colon here, judge if as pseudo code, thanks)
Question is: How to iterate through the list and make an if else statements to each of the elements I encounter
P.S. homework tag should be presented, but I do not have reputation enough yet for making new tags
Thanks!
Aucun commentaire:
Enregistrer un commentaire