This Text file is old! In a 🏛️Museum, an unsorted archive of (user-)pages. (Saved from Geocities in Oct-2009. The archival story: oocities.org)
--------------------------------------- (To 🚫report any bad content: archivehelp @ gmail.com)
>

; zipstrange1.scm - unfold examples from oxford unfold paper.

;-------------------------------------------------------------
(display "level order traversal")(newline)

; chicken's definition only works with lists of the same size
;(define (zip list1 . more-lists) (apply map list list1 more-lists))

; this defintion also only works with lists of the same size
;(define (zip l1 l2)
;   (cond 
;      ((null? l1) '())
;      (else (cons (list (car l1) (car l2)) (zip (cdr l1) (cdr l2))))))

;lzw :: (a->a->a) -> [a] -> [a] -> [a]
;lzw op xs ys
;   | null xs = ys
;   | null ys = xs
;   | otherwise = (head xs `op` head ys) :
;                    lzw op (tail xs) (tail ys)

(define (lzw op xs ys)
   (display (format "~%xs:~A, ys:~A" xs ys))
   (cond 
     ((null? xs) ys)
     ((null? ys) xs)
     (else 
       (cons (op (car xs) (car ys)) (lzw op (cdr xs) (cdr ys)) ) ))) 

(lzw list '(a b c d e) '(1 2 3 4 5))
(lzw list '(a b c d e f) '(1 2 3 4 5))
(lzw list '(a b c d e) '(1 2 3 4 5 6))



;------------------------------------------------------------------
; zip-with returns a list of size equal to the short of the two of its arguments

;zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]
;zipWith f (x:xs) (y:ys) = f x y : zipWith f xs ys
;zipWith f _ _  = []

(define (zip-with f x y)
   (cond
     ((or (null? x) (null? y)) '())
     (else 
        (cons (f (car x) (car y)) (zip-with f (cdr x) (cdr y))) )))

(zip-with list '(a b c d e) '(1 2 3 4 5))
(zip-with list '(a b c d e f) '(1 2 3 4 5))
(zip-with list '(a b c d e) '(1 2 3 4 5 6))

;------------------------------------------------------------------
(display "lzc")(newline)

;lzc :: [[a]] -> [[a]] -> [[a]]
;lzc = lzw (++)

(define (lzc xs ys)
   (lzw append xs ys))

(lzc '((a b) (c d) (e)) '((1 2) (3) (4 5)) )
(lzc '((a b c) (d) (e f)) '((1 2) (3 4 5)) )
(lzc '((a b c d e)) '(() (1 2 3 4 5 6)))

;----------------------------------------------------------

Text file Source (historic): geocities.com/soho/square/3472

geocities.com/soho/square
geocities.com/soho

(to report bad content: archivehelp @ gmail)