Generalize the type of pretty-print-set.
This commit is contained in:
parent
5bc062af54
commit
0e364eb52d
2 changed files with 5 additions and 3 deletions
|
@ -366,12 +366,13 @@ those symbols.
|
|||
|
||||
@section[#:tag "utils_Pretty_printing"]{Pretty printing}
|
||||
|
||||
@defproc[(pretty-print-set (s (Setof Any))) String]{
|
||||
@defproc[(pretty-print-set [s (U (Setof Any) (Listof Any))]) String]{
|
||||
|
||||
Pretty prints a set by listing its elements in alphabetic order.
|
||||
|
||||
@ex[
|
||||
(pretty-print-set (set 'a 'b 1))
|
||||
(pretty-print-set (list 'a 'b 1))
|
||||
]}
|
||||
|
||||
@defproc[(pretty-print-set-sets [ms (U (Listof (Setof Any)) (Setof (Setof Any)))])
|
||||
|
|
|
@ -347,13 +347,14 @@
|
|||
(check-equal? (list-sets->list-strings (list (set 'x 'y) (set 'z) (set) (set 't)))
|
||||
'("x y" "z" "" "t"))))
|
||||
|
||||
(: pretty-print-set (-> (Setof Any) String))
|
||||
(: pretty-print-set (-> (U (Setof Any) (Listof Any)) String))
|
||||
(define (pretty-print-set s)
|
||||
(string-join (sort (set-map s any->string) string<?)))
|
||||
|
||||
(module+ test
|
||||
(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")
|
||||
(check-equal? (pretty-print-set (list 'a 'b 1)) "1 a b")))
|
||||
|
||||
(: pretty-print-set-sets (-> (U (Setof (Setof Any))
|
||||
(Listof (Setof Any)))
|
||||
|
|
Loading…
Reference in a new issue