我想我几乎已经解决了以前的问题:Foldr in scheme but in code is a little trouble. 我需要#t,但我得到第一个元素,false 是可以的。这是我的代码:
(define accum
(lambda (list1 pre?)
(foldr (lambda (x y)
(if y
(if (or (equal? y #t) (pre? x y))
x
#f)
#f))
#t
list1)))
(accum '(1 2 3 4) <=) --> 1 (should be #t)
(accum '(2 2 4 4) <=) --> 2 (should be #t)
(accum '(1 2 5 4) <=) --> #f
(accum '(5 7 2 3) <=) --> #f
如果我写“x --> #t”,我总是得到#t,即使是#f。