Generalize the type of pretty-print-set-sets.

This commit is contained in:
Sergiu Ivanov 2023-08-17 11:33:47 +02:00
parent 99d50c8505
commit 5bc062af54
2 changed files with 8 additions and 3 deletions

View File

@ -374,7 +374,8 @@ Pretty prints a set by listing its elements in alphabetic order.
(pretty-print-set (set 'a 'b 1)) (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. Pretty-prints a set of sets of symbols.
@ -383,6 +384,7 @@ a state graph.
@ex[ @ex[
(pretty-print-set-sets (set (set 'a 'b) (set 'c))) (pretty-print-set-sets (set (set 'a 'b) (set 'c)))
(pretty-print-set-sets (list (set 'a 'b) (set 'c)))
]} ]}
@section{Additional graph utilities} @section{Additional graph utilities}

View File

@ -355,14 +355,17 @@
(test-case "pretty-print-set" (test-case "pretty-print-set"
(check-equal? (pretty-print-set (set 'a 'b 1)) "1 a b"))) (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) (define (pretty-print-set-sets ms)
(string-join (for/list ([m ms]) : (Listof String) (string-join (for/list ([m ms]) : (Listof String)
(format "{~a}" (pretty-print-set m))) "")) (format "{~a}" (pretty-print-set m))) ""))
(module+ test (module+ test
(test-case "pretty-print-set-sets" (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)) (define dotit (compose display graphviz))