utils: Add pretty-print-set.
This commit is contained in:
parent
1e524f167c
commit
3f24a5be8b
2 changed files with 14 additions and 1 deletions
|
@ -107,3 +107,6 @@
|
|||
(check-false (has-edge? new-gr3 'cc 'bb))
|
||||
(check-equal? (edge-weight new-gr3 'aa 'bb) 20)
|
||||
(check-equal? (edge-weight new-gr3 'bb 'cc) 22)))
|
||||
|
||||
(test-case "Pretty printing"
|
||||
(check-equal? (pretty-print-set (set 'a 'b 1)) "1 a b"))
|
||||
|
|
12
utils.rkt
12
utils.rkt
|
@ -23,7 +23,8 @@
|
|||
[update-graph (->* (graph?)
|
||||
(#:v-func (-> any/c any/c)
|
||||
#:e-func (-> any/c any/c))
|
||||
graph?)])
|
||||
graph?)]
|
||||
[pretty-print-set (-> generic-set? string?)])
|
||||
;; Contracts
|
||||
(contract-out [variable-mapping? contract?]
|
||||
[string-variable-mapping? contract?]
|
||||
|
@ -249,3 +250,12 @@
|
|||
(if (unweighted-graph? gr)
|
||||
(unweighted-graph/directed edges)
|
||||
(weighted-graph/directed edges))))
|
||||
|
||||
|
||||
;;; ===============
|
||||
;;; Pretty printing
|
||||
;;; ===============
|
||||
|
||||
;;; Pretty print a set by listing its elements in alphabetic order.
|
||||
(define (pretty-print-set s)
|
||||
(string-join (sort (set-map s any->string) string<?)))
|
||||
|
|
Loading…
Reference in a new issue