diff options
author | Andreas Widen <andreas@harmonicflow.org> | 2023-11-25 17:21:37 +0100 |
---|---|---|
committer | Andreas Widen <andreas@harmonicflow.org> | 2023-11-25 17:21:37 +0100 |
commit | 1b2b7c3eb939724696894f31ff27db97b0cac84c (patch) | |
tree | efb7b7746a628efb7bb99b2e44c9c2fbfd75b656 /apps/aux/numbers.scm | |
download | hf-web-1b2b7c3eb939724696894f31ff27db97b0cac84c.tar.xz hf-web-1b2b7c3eb939724696894f31ff27db97b0cac84c.zip |
Initial commit.
Signed-off-by: Andreas Widen <andreas@harmonicflow.org>
Diffstat (limited to 'apps/aux/numbers.scm')
-rw-r--r-- | apps/aux/numbers.scm | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/apps/aux/numbers.scm b/apps/aux/numbers.scm new file mode 100644 index 0000000..6c83dcb --- /dev/null +++ b/apps/aux/numbers.scm @@ -0,0 +1,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))))) |