>>42
Shouldn't the last case be
(1 1.5 ...), unless I misunderstood what the intent of the code was, if given:
1 argument - generate a list from 0 to * given increments/steps of 1, so that you get "first argument" elements.
2 arguments - generate a list from "first argument" to "second argument" given increments/steps of 1
3 arguments - generate a list from "first argument" to "second argument" given increments/steps of "third argument".
Here's my attempt to write this in CL:
(defun seq (start-or-count &optional (end (1- start-or-count) end-present-p)
(by 1) &aux (start (if end-present-p start-or-count 0)))
(loop for i from start to end by by collect i))
(defmacro range (&rest args)
(if (every #'constantp args) `(list ,@(apply #'seq args)) `(seq ,@args)))
Difference from your examples is that the third example is ran at compile-time as
(+ 9 1) will be detected by my implementation as a constant (most implementations will do this, but they are not required by the standard to do it properly: how well a constant form will be detected depends on your implementation's own optimization code - CL merely gives access to this functionality, but only /recommends/ that compilers perform such optimizations).