[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] 01/03: Add printers for <intmap> and <transient-intmap>

From: Andy Wingo
Subject: [Guile-commits] 01/03: Add printers for <intmap> and <transient-intmap>
Date: Fri, 08 May 2015 11:09:14 +0000

wingo pushed a commit to branch master
in repository guile.

commit 6ffb6e69ed1232d31d61f9330b654c1bc43af2a7
Author: Andy Wingo <address@hidden>
Date:   Fri May 8 11:13:39 2015 +0200

    Add printers for <intmap> and <transient-intmap>
    * module/language/cps/intmap.scm (intmap->alist, print-intmap)
      (print-transient-intmap): New functions.
      Install the new functions as printers for <intmap> and <transient-intmap>.
 module/language/cps/intmap.scm |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/module/language/cps/intmap.scm b/module/language/cps/intmap.scm
index 7ab8f67..146b550 100644
--- a/module/language/cps/intmap.scm
+++ b/module/language/cps/intmap.scm
@@ -32,6 +32,7 @@
 (define-module (language cps intmap)
   #:use-module (srfi srfi-9)
+  #:use-module (srfi srfi-9 gnu)
   #:use-module (srfi srfi-18)
   #:use-module (ice-9 match)
   #:export (empty-intmap
@@ -590,3 +591,14 @@
           ((eq? root a-root) a)
           ((eq? root b-root) b)
           (else (make-intmap/prune a-min a-shift root)))))))))
+(define (intmap->alist intmap)
+  (reverse (intmap-fold acons intmap '())))
+(define (print-intmap intmap port)
+  (format port "#<intmap ~a>" (intmap->alist intmap)))
+(define (print-transient-intmap intmap port)
+  (format port "#<transient-intmap ~a>" (intmap->alist intmap)))
+(set-record-type-printer! <intmap> print-intmap)
+(set-record-type-printer! <transient-intmap> print-transient-intmap)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]