I think
subseq is the function you are looking for. (subseq does require the indices you give to be within bounds though.)
Further, your code snippet seems to look like you haven't fully understood s-expressions yet. Note that the LOOP macro has a weird little language of its own there. You might want to stay away from it until you understand how to do things without loop. (There are alternatives to LOOP that are much better imo, but i guess loop is acceptable.)
It is usual and natural not to put ending parentheses on a new line, like C(++, whatever) curly hooks {}.
If you want to make a variable, 99% of the cases you use LET, almost never DEFVAR, and SETQ, SETF are for setting variables/things. (I never use SETQ, i don't get it, lol, nah think it is only for setting variables.)
A good directly readable online book to get started. (Look under
variables to see how LET works. Basically you have an area where the variable creation/setting go and where the body of the code goes. (Although one can make macros that makes C-like scopes, but for me not using them pushes me -me at least- to make better code.)
Making a version of subseq is good practice, i suggest doing it with DO, LET or recursively. If you want UNTIL: (WHILE is easy from this, of course.)
- Code: Select all
(defmacro until (cond &body body) `(do () (,cond (values)) ,@body))
(let ((i 0))
(until (> i 10)
(print i)
(setf i (+ i 1))))
(This is a pretty crude way to program lisp though.)
Btw, do not use L as a variable, 'l' looks like 1.