Guile Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Scheme style auto-resizing hashtable (fwd)
I lost the beginning of your discussion, but could your iterators be a
cons cell where the cdr value is delayed?
This would be neater, if cdr, map and for-each implicitly forced the
cdr, but for the below example I define ++ to replace cdr.
Like this:
(define (hash->list v)
(let ((l (vector-length v)))
(define (h2l v nth handles)
(cond
((= nth l) ())
((pair? handles) (cons (car handles)
(delay (h2l v nth (cdr handles)))))
((= (1+ nth) l) ())
(else
(h2l v (1+ nth) (vector-ref v (1+ nth))))))
(h2l v -1 ())))
(define (++ c)
(force (cdr c)))
(define t (make-hash-table 13))
(hashq-set! t 'a 'b)
(hash->list t) => ((a . b) . #<promise #<procedure ()>>)
(++ (hash->list t)) => ()
--
Marko Kohtala - Marko.Kohtala@ntc.nokia.com, Marko.Kohtala@hut.fi
Guile Home |
Main Index |
Thread Index