Implement range* as in-inclusive-range.
This commit is contained in:
parent
41a8c960b8
commit
63fd991e58
10
lib.rkt
10
lib.rkt
|
@ -194,14 +194,8 @@
|
||||||
(define (snoc lst v)
|
(define (snoc lst v)
|
||||||
(append lst (list v)))
|
(append lst (list v)))
|
||||||
|
|
||||||
;; range* : number? -> (listof number?)
|
;; range* : number? -> number? -> [number?] -> (streamof number?)
|
||||||
;; range* : number? -> number? -> [number?] -> (listof number?)
|
(define range* in-inclusive-range)
|
||||||
;; Like range, but with an inclusive right end
|
|
||||||
(define-syntax range*
|
|
||||||
(syntax-rules ()
|
|
||||||
[(_ n) (range (add1 n))]
|
|
||||||
[(_ from to) (range from (add1 to))]
|
|
||||||
[(_ from to step) (range from (add1 to) step)]))
|
|
||||||
|
|
||||||
;; scanl : (a -> a -> a) -> (listof a) -> (listof a)
|
;; scanl : (a -> a -> a) -> (listof a) -> (listof a)
|
||||||
;; foldl that accumulates partial results in a list
|
;; foldl that accumulates partial results in a list
|
||||||
|
|
Loading…
Reference in New Issue