From 5bc062af546857579cec4fc3611fc07c8b3aae16 Mon Sep 17 00:00:00 2001 From: Sergiu Ivanov Date: Thu, 17 Aug 2023 11:33:47 +0200 Subject: [PATCH] Generalize the type of pretty-print-set-sets. --- scribblings/utils.scrbl | 4 +++- utils.rkt | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/scribblings/utils.scrbl b/scribblings/utils.scrbl index b177ec9..f09d8c8 100644 --- a/scribblings/utils.scrbl +++ b/scribblings/utils.scrbl @@ -374,7 +374,8 @@ Pretty prints a set by listing its elements in alphabetic order. (pretty-print-set (set 'a 'b 1)) ]} -@defproc[(pretty-print-set-sets (ms (Setof (Setof Any)))) String]{ +@defproc[(pretty-print-set-sets [ms (U (Listof (Setof Any)) (Setof (Setof Any)))]) + String]{ Pretty-prints a set of sets of symbols. @@ -383,6 +384,7 @@ a state graph. @ex[ (pretty-print-set-sets (set (set 'a 'b) (set 'c))) +(pretty-print-set-sets (list (set 'a 'b) (set 'c))) ]} @section{Additional graph utilities} diff --git a/utils.rkt b/utils.rkt index 4f1a7ae..ecc9c62 100644 --- a/utils.rkt +++ b/utils.rkt @@ -355,14 +355,17 @@ (test-case "pretty-print-set" (check-equal? (pretty-print-set (set 'a 'b 1)) "1 a b"))) -(: pretty-print-set-sets (-> (Setof (Setof Any)) String)) +(: pretty-print-set-sets (-> (U (Setof (Setof Any)) + (Listof (Setof Any))) + String)) (define (pretty-print-set-sets ms) (string-join (for/list ([m ms]) : (Listof String) (format "{~a}" (pretty-print-set m))) "")) (module+ test (test-case "pretty-print-set-sets" - (check-equal? (pretty-print-set-sets (set (set 'a 'b) (set 'c))) "{a b}{c}"))) + (check-equal? (pretty-print-set-sets (set (set 'a 'b) (set 'c))) "{a b}{c}") + (check-equal? (pretty-print-set-sets (list (set 'a 'b) (set 'c))) "{a b}{c}"))) (define dotit (compose display graphviz))