Created
February 5, 2012 18:05
-
-
Save ijp/1746935 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; untested | |
(define-record-type end) | |
(define-record-type (node %node node?) | |
(fields (immutable left %left) | |
(immutable value value) | |
(immutable right %right))) | |
(define-syntax-rule (node left value right) | |
(%node (delay left) value (delay right))) | |
(define left (compose force %left)) | |
(define right (compose force %right)) | |
(define (list->dllist list) | |
(define (next list prev) | |
(if (null? list) | |
(make-end) | |
(letrec ((this (node prev (car list) (next (cdr list) this)))) | |
this))) | |
(next list (make-end))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment