public
Created

  • Download Gist
dllist.scm
Scheme
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
;; 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)))

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.