Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gendl
gendl
Commits
fc6ef0b2
Commit
fc6ef0b2
authored
Mar 18, 2015
by
Dave Cooper
Browse files
merged enhanced/corrected version of list-of-numbers from REC
parent
c2854726
Changes
1
Hide whitespace changes
Inline
Side-by-side
base/rest/source/utilities.lisp
View file @
fc6ef0b2
...
...
@@ -124,6 +124,30 @@ object in <b>object-list</b>.
(
the-object
object
(
evaluate
message
)))
object-list
)))
(
defun
list-of-numbers
(
num1
num2
&optional
(
increment
1
)
(
tolerance
(
/
increment
10
)))
"List of Numbers. Returns a list of incrementing numbers starting
from <b>num1</b> and ending with <b>num2</b>, inclusive. Increment can
be positive for num1 < num2, or negative for num1 > num2. This version
was contributed by Reinier van Dijk.
:arguments (num1 \"Number\"
num2 \"Number\")
:&optional ((increment 1) \"Number. The distance between the returned listed numbers.\"
(tolerance (/ increment 10)) \"Number. tolerance for increment.\")"
(
cond
((
zerop
increment
)
(
error
"increment of zero is not allowed"
))
((
and
(
<
increment
0.0
)
(
>
num2
num1
))
(
error
"increment is negative, while difference between num2 and num1 is positive."
))
((
and
(
>
increment
0.0
)
(
<
num2
num1
))
(
error
"increment is positive, while difference between num2 and num1 is negative."
))
(
t
(
let
((
predicate
(
if
(
>
increment
0.0
)
#'
>=
#'
<=
))
(
result-list
nil
))
(
do
((
num
num1
(
+
num
increment
)))
((
or
(
funcall
predicate
num
num2
)
(
<
(
abs
(
-
num2
num
))
tolerance
))
(
nreverse
(
cons
num2
result-list
)))
(
push
num
result-list
))))))
;;
;; FLAG -- remove this when above version is fully tested.
;;
#+
nil
(
defun
list-of-numbers
(
num1
num2
&optional
(
increment
1
))
"List of Numbers. Returns a list of incrementing numbers starting from
<b>num1</b> and ending with <b>num2</b>, inclusive.
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment