From ce0aeb4a774511bfbd9ea06b056d3c9b63700934 Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Thu, 17 Nov 2022 22:05:04 +0100 Subject: add range without arguments --- mew.scm | 1 + mew.svnwiki | 7 +++++-- tests/test.mew | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/mew.scm b/mew.scm index 7756746..51c3e47 100644 --- a/mew.scm +++ b/mew.scm @@ -389,6 +389,7 @@ (define range (case-lambda + (() (make-range-generator 0 +inf.0 1)) ((start) (make-range-generator start +inf.0 1)) ((start end) (make-range-generator start end 1)) ((start end step) (set! start (- (+ start step) step)) diff --git a/mew.svnwiki b/mew.svnwiki index 03d91c7..c248917 100644 --- a/mew.svnwiki +++ b/mew.svnwiki @@ -349,9 +349,12 @@ Generic generator for list/vector/string/hash-table/generator. Alias for {{circular-generator}}. -(range ? ?) +(range ? ? ?) -A variant of {{make-range-generator}} that also allows negative {{step}}. +A variant of {{make-range-generator}} that also allows negative {{}}. +{{}} defaults to zero. +{{}} defaults to infinity. +{{}} defaults to 1. (giterate ) diff --git a/tests/test.mew b/tests/test.mew index b895780..daeffc1 100644 --- a/tests/test.mew +++ b/tests/test.mew @@ -31,6 +31,7 @@ (test '(1 3 5) (into '() (range 1 7 2))) (test '(3 2 1) (into '() (range 3 0 -1))) (test '(2 3 4) (into '() (gtake (range 2) 3))) + (test '(0 1 2) (into '() (gtake (range) 3))) (test '(1 3/2 2 5/2) (into '() (gtake (range 1 +inf.0 1/2) 4))) (test '(1 1 1 1) (into '() (gtake (range 1 +inf.0 0) 4)))) -- cgit 1.4.1