mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-24 20:45:06 +02:00
Experimenting with faster versions of map, for-each
This commit is contained in:
parent
6d9c55eb0d
commit
48845ce23b
1 changed files with 13 additions and 0 deletions
|
@ -83,6 +83,8 @@
|
||||||
make-list
|
make-list
|
||||||
list-copy
|
list-copy
|
||||||
map
|
map
|
||||||
|
Cyc-map-loop-1
|
||||||
|
Cyc-for-each-loop-1
|
||||||
for-each
|
for-each
|
||||||
list-tail
|
list-tail
|
||||||
list-ref
|
list-ref
|
||||||
|
@ -786,6 +788,17 @@
|
||||||
;; Fast path.
|
;; Fast path.
|
||||||
(foldr (lambda (x y) (cons (f x) y)) '() lis1)))
|
(foldr (lambda (x y) (cons (f x) y)) '() lis1)))
|
||||||
|
|
||||||
|
;; Experimenting with faster versions of map, for-each
|
||||||
|
(define (Cyc-map-loop-1 f lst)
|
||||||
|
(if (null? lst)
|
||||||
|
'()
|
||||||
|
(cons (f (car lst)) (Cyc-map-loop-1 f (cdr lst)))))
|
||||||
|
(define (Cyc-for-each-loop-1 f lst)
|
||||||
|
(if (null? lst)
|
||||||
|
'()
|
||||||
|
(begin (f (car lst))
|
||||||
|
(Cyc-for-each-loop-1 f (cdr lst)))))
|
||||||
|
|
||||||
(define (for-each f lis1 . lists)
|
(define (for-each f lis1 . lists)
|
||||||
(if (not (null? lis1))
|
(if (not (null? lis1))
|
||||||
(if (pair? lists)
|
(if (pair? lists)
|
||||||
|
|
Loading…
Add table
Reference in a new issue