Name: Anonymous 2013-01-17 2:23
Integrating zippers into the very core of Lisp as a replacement/enhancement of cons lists.
Discuss.
Discuss.
(library (my-sheiit zippers)
(export make-zipper zipper zup-list zdown-list zdown zup zdown-null? zup-null? zup-car zdown-car)
(import (rnrs))
(define (make-zipper behind forward)
(cons behind forward))
(define (zipper . lis)
(make-zipper '() lis))
(define zup-list car)
(define zdown-list cdr)
(define (zup-null? z)
(null? (zup-list z)))
(define (zdown-null? z)
(null? (zdown-list z)))
(define (zup-car z)
(assert (not (zup-null? z)))
(car (zup-list z)))
(define (zdown-car z)
(assert (not (zdown-null? z)))
(car (zdown-list z)))
(define (zup z)
(assert (not (zup-null? z)))
(make-zipper (cdr (zup-list z))
(cons (zup-car z) (zdown-list z))))
(define (zdown z)
(assert (not (zdown-null? z)))
(make-zipper (cons (zdown-car z) (zup-list z))
(cdr (zdown-list z)))))