[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
reading job-specifier.scm
From: |
Wensheng Xie |
Subject: |
reading job-specifier.scm |
Date: |
Thu, 13 Jan 2022 21:46:25 +0800 |
User-agent: |
Evolution 3.38.3-1 |
Hi,
when reading the code of mcron, for example, the file job-
specifier.scm, I noted that the following code
```
(define* (range start end #:optional (step 1))
"Produces a list of values from START up to (but not including) END.
An
optional STEP may be supplied, and (if positive) only every step'th
value will
go into the list. For example, (range 1 6 2) returns '(1 3 5)."
(let ((step* (max step 1)))
(unfold (λ (i) (>= i end)) ;predicate
identity ;value
(λ (i) (+ step* i)) ;next seed
start))) ;seed
```
I want to understand what is the advantage here. Why don't you write it
like
```
(define* (range start end #:optional (step 1))
"Produces a list of values from START up to (but not including) END.
An
optional STEP may be supplied, and (if positive) only every step'th
value will
go into the list. For example, (range 1 6 2) returns '(1 3 5)."
(let ((step* (max step 1)))
(if (>= start end)
'()
(cons start (range (+ start step*) end step*))))
```
best regards,
wxie
signature.asc
Description: This is a digitally signed message part
- reading job-specifier.scm,
Wensheng Xie <=