Make (foldl ...) state the second argument, as with (foldr ...).

This commit is contained in:
Jesse D. McDonald 2010-04-11 07:28:59 -05:00
parent c6500a53b3
commit 2d7b079dd8
1 changed files with 7 additions and 7 deletions

View File

@ -1,16 +1,16 @@
;; Fold a function over a list; left-associative
;; (foldl fn init lst)
;; ==> (foldl fn (fn init (car lst)) (cdr lst))
;; ==> (foldl fn (fn (car lst) init) (cdr lst))
; (define (foldl fn init lst)
; (if (pair? lst)
; (foldl fn (fn init (car lst)) (cdr lst))
; (foldl fn (fn (car lst) init) (cdr lst))
; init))
#0=#S(#="lambda"
; (define (foldl fn init lst)
; ((if (pair? lst)
; (lambda () (foldl fn (fn init (car lst)) (cdr lst))
; (lambda () (foldl fn (fn (car lst) init) (cdr lst))
; (lambda () init))))
#(
#S(#="template"
@ -30,7 +30,7 @@
; (call-with-multiple-values
; (lambda (new-init)
; (k (foldl fn new-init (cdr lst))))
; (lambda () (fn init (car lst))))))
; (lambda () (fn (car lst) init)))))
#(
#S(#="template"
; (lambda (new-init)
@ -51,9 +51,9 @@
)
"\x80\x81\x82" ; f0=fn f1=init f2=lst
2
"\x00\x80\x03\x42\; (set! f0 (car i2))
\x02\x80\x80\x00\; (set! f0 (cons f0 nil))
\x02\x80\x41\x80\; (set! f0 (cons i1 f0))
"\x02\x80\x41\x00\; (set! f0 (cons i1 nil))
\x00\x81\x03\x42\; (set! f1 (car i2))
\x02\x80\x81\x80\; (set! f0 (cons f1 f0))
\x00\x81\x1b\x01"; (set! f1 (lambda g1))
0x40 ; i0
0x80 ; f0