Replaced for-each function with faster alternative

Added scheme_error() for error reporting from C code
load-extension exists now, althought it does not do what I want
Added timeit-start, timeit-end and timeit-result functions for easier timing
Some map, and my map timing for comparison
This commit is contained in:
Sanel Zukan
2008-07-15 16:00:41 +00:00
parent 3cf7bd04c7
commit 192b61316b
10 changed files with 104 additions and 54 deletions

View File

@@ -197,15 +197,27 @@
(cdrs (cdr unz)))
(cons (apply proc cars) (apply map (cons proc cdrs)))))))
(define (for-each proc . lists)
(if (null? lists)
(apply proc)
(if (null? (car lists))
#t
(let* ((unz (apply unzip1-with-cdr lists))
(cars (car unz))
(cdrs (cdr unz)))
(apply proc cars) (apply map (cons proc cdrs))))))
;;
;; Original implementation that pretty sucks
;; Althought it behaves as given in Dybvig's book, PLT and chicken
;; versions does not allow multiple list arguments
;;
;(define (for-each proc . lists)
; (if (null? lists)
; (apply proc)
; (if (null? (car lists))
; #t
; (let* ((unz (apply unzip1-with-cdr lists))
; (cars (car unz))
; (cdrs (cdr unz)))
; (apply proc cars) (apply map (cons proc cdrs))))))
(define (for-each proc lst)
(if (null? lst)
lst
(begin
(proc (car lst))
(for-each proc (cdr lst)))))
(define (list-tail x k)
(if (zero? k)