コンスセルを使った循環のあるグラフをコピーする関数は次のように書ける。
(define (copy-graph-sub ht graph)
  (cond ((not (pair? graph)) graph)
	((hash-table-exists? ht graph)
	 (hash-table-ref ht graph))
	(else
	 (let ((p (cons #f #f)))
	   (hash-table-set! ht graph p)
	   (set-car! p (copy-graph-sub ht (car graph)))
	   (set-cdr! p (copy-graph-sub ht (cdr graph)))
	   p))))
(define (copy-graph graph)
  (copy-graph-sub (make-hash-table) graph))
ハッシュテーブルの操作はSRFI-69に沿っている。
Gauche では hash-table-ref は hash-table-get, hash-table-set! は hash-table-put! と書くみたい。