[Scheme]如何定义一个没有初始值的reduce

在chezscheme中用fold-left(也就是reduce)时,我发现fold系列函数都要提供一个初始值,可是在Clojure中确不是这样的

> (define nums '(1 2 3 4))
(1 2 3 4)
>(fold-left max (car nums) (cdr nums))
4

>(fold-left max nums)
Exception: incorrect argument count in call (fold-left max nums)
Type (debug) to enter the debugger.
=> (def nums [1 2 3 4])
[1 2 3 4]

=> (reduce max nums)
4

=> (reduce max (first nums) (rest nums))
4

我想知道Clojure的这种没有初始值的reduce是怎么实现的,能不能用Scheme也写一个

虽然不用clojure和scheme,但我觉得clojure这种是把列表的第一个输入做为了所谓的默认值。

或者,可能定义了所有基础类型的单位半群

foldlfoldl1 的区别罢了

(define (reduce fn xs) (if (null? xs) (fn) (fold-left fn (car xs) (cdr xs)))

好吧,看来我想的太复杂了