mirror of
https://github.com/edeproject/ede.git
synced 2023-08-10 21:13:03 +03:00
Replaced map impl. with the better one. At least faster...
This commit is contained in:
parent
71bb4b94d8
commit
23cf161b16
@ -187,15 +187,39 @@
|
|||||||
(append cars (list car1))
|
(append cars (list car1))
|
||||||
(append cdrs (list cdr1))))))
|
(append cdrs (list cdr1))))))
|
||||||
|
|
||||||
(define (map proc . lists)
|
;;
|
||||||
(if (null? lists)
|
;; Original implementation that pretty sucks
|
||||||
(apply proc)
|
;;
|
||||||
(if (null? (car lists))
|
;(define (map proc . lists)
|
||||||
'()
|
; (if (null? lists)
|
||||||
(let* ((unz (apply unzip1-with-cdr lists))
|
; (apply proc)
|
||||||
(cars (car unz))
|
; (if (null? (car lists))
|
||||||
(cdrs (cdr unz)))
|
; '()
|
||||||
(cons (apply proc cars) (apply map (cons proc cdrs)))))))
|
; (let* ((unz (apply unzip1-with-cdr lists))
|
||||||
|
; (cars (car unz))
|
||||||
|
; (cdrs (cdr unz)))
|
||||||
|
; (cons (apply proc cars) (apply map (cons proc cdrs)))))))
|
||||||
|
|
||||||
|
(define (map1 proc lst)
|
||||||
|
(if (null? lst)
|
||||||
|
lst
|
||||||
|
(let loop ((lst lst)
|
||||||
|
(nls '()))
|
||||||
|
(if (null? lst)
|
||||||
|
(reverse nls)
|
||||||
|
(loop (cdr lst)
|
||||||
|
(cons (proc (car lst)) nls))))))
|
||||||
|
|
||||||
|
(define (map proc lst . more)
|
||||||
|
(if (null? more)
|
||||||
|
(map1 proc lst)
|
||||||
|
(let map-more ((lst lst)
|
||||||
|
(more more))
|
||||||
|
(if (null? lst)
|
||||||
|
lst
|
||||||
|
(cons (apply proc (car lst) (map car more))
|
||||||
|
(map-more (cdr lst)
|
||||||
|
(map cdr more)))))))
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;; Original implementation that pretty sucks
|
;; Original implementation that pretty sucks
|
||||||
|
Loading…
Reference in New Issue
Block a user