mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-24 20:45:06 +02:00
Allow for-each to accept multiple list args
This commit is contained in:
parent
73ea931dfa
commit
0f8f6c2efe
1 changed files with 25 additions and 33 deletions
|
@ -606,14 +606,6 @@
|
||||||
(make k x)))
|
(make k x)))
|
||||||
(define (list-copy lst)
|
(define (list-copy lst)
|
||||||
(foldr (lambda (x y) (cons x y)) '() lst))
|
(foldr (lambda (x y) (cons x y)) '() lst))
|
||||||
; (define (map func lst)
|
|
||||||
; (foldr (lambda (x y) (cons (func x) y)) '() lst))
|
|
||||||
(define (for-each f lst)
|
|
||||||
(cond
|
|
||||||
((null? lst) #t)
|
|
||||||
(else
|
|
||||||
(f (car lst))
|
|
||||||
(for-each f (cdr lst)))))
|
|
||||||
;; Implementation of receive from SRFI 8
|
;; Implementation of receive from SRFI 8
|
||||||
(define-syntax receive
|
(define-syntax receive
|
||||||
(er-macro-transformer
|
(er-macro-transformer
|
||||||
|
@ -663,20 +655,20 @@
|
||||||
;; Fast path.
|
;; Fast path.
|
||||||
(foldr (lambda (x y) (cons (f x) y)) '() lis1)))
|
(foldr (lambda (x y) (cons (f x) y)) '() lis1)))
|
||||||
|
|
||||||
;;(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)
|
||||||
;; (let recur ((lists (cons lis1 lists)))
|
(let recur ((lists (cons lis1 lists)))
|
||||||
;; (receive (cars cdrs) (%cars+cdrs lists)
|
(receive (cars cdrs) (%cars+cdrs lists)
|
||||||
;; (if (pair? cars)
|
(if (pair? cars)
|
||||||
;; (begin
|
(begin
|
||||||
;; (apply f cars)
|
(apply f cars)
|
||||||
;; (recur cdrs)))))
|
(recur cdrs)))))
|
||||||
;; ;; Fast path.
|
;; Fast path.
|
||||||
;; (if (eq? 1 (length lis1))
|
(if (eq? 1 (length lis1))
|
||||||
;; (f (car lis1))
|
(f (car lis1))
|
||||||
;; (begin (f (car lis1))
|
(begin (f (car lis1))
|
||||||
;; (for-each f (cdr lis1)))))))
|
(for-each f (cdr lis1)))))))
|
||||||
(define (list-tail lst k)
|
(define (list-tail lst k)
|
||||||
(if (zero? k)
|
(if (zero? k)
|
||||||
lst
|
lst
|
||||||
|
|
Loading…
Add table
Reference in a new issue