blob: 6c83dcbc59bbc5910cdb825f547459ad08d2a04e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
;;; Harmonic Flow web site
(define-module (apps aux numbers)
#:use-module (srfi srfi-1)
#:export (minus-one
plus-one
range))
(define (minus-one n)
"Return N-1."
(- n 1))
(define (plus-one n)
"Return N+1."
(+ n 1))
(define (range a b)
"Return the list of integers in the range [A, B].
A (integer)
B (integer)
RETURN VALUE (list of integers)
For example, for the range [-2, 3], return
(list -2 -1 0 1 2 3)."
(cond ((zero? (- a b)) (cons a (list)))
(else (cons a (range (plus-one a) b)))))
|