utils: Add read-symbol-list.

This commit is contained in:
Sergiu Ivanov 2020-12-22 23:10:05 +01:00
parent fe989ef8a7
commit 2af5656e71
3 changed files with 18 additions and 3 deletions

View file

@ -214,6 +214,14 @@ Typeset the graph via graphviz and display it.
} }
@defproc[(read-symbol-list (str String)) (Listof Symbol)]{
Reads a list of symbols from a string.
@examples[#:eval utils-evaluator
(read-symbol-list "a b c")
]}
@section{Additional graph utilities} @section{Additional graph utilities}
@section{Pretty printing} @section{Pretty printing}

View file

@ -10,8 +10,7 @@
(provide (provide
;; Functions ;; Functions
(contract-out [read-symbol-list (-> string? (listof symbol?))] (contract-out [drop-first-last (-> string? string?)]
[drop-first-last (-> string? string?)]
[list-sets->list-strings (-> (listof (set/c any/c)) (listof string?))] [list-sets->list-strings (-> (listof (set/c any/c)) (listof string?))]
[pretty-print-set-sets (-> (set/c (set/c symbol?) #:kind 'dont-care) string?)] [pretty-print-set-sets (-> (set/c (set/c symbol?) #:kind 'dont-care) string?)]
[update-vertices/unweighted (-> graph? (-> any/c any/c) graph?)] [update-vertices/unweighted (-> graph? (-> any/c any/c) graph?)]

View file

@ -9,7 +9,7 @@
extract-symbols extract-symbols
any->string stringify-variable-mapping string->any map-sexp any->string stringify-variable-mapping string->any map-sexp
read-org-sexp unorg unstringify-pairs read-org-sexp unorg unstringify-pairs
read-org-variable-mapping unorgv read-org-variable-mapping unorgv read-symbol-list
;; Syntax ;; Syntax
auto-hash-ref/explicit auto-hash-ref/:) auto-hash-ref/explicit auto-hash-ref/:)
@ -254,3 +254,11 @@
(: dotit (-> Graph Void)) (: dotit (-> Graph Void))
(define dotit (compose display graphviz)) (define dotit (compose display graphviz))
(: read-symbol-list (-> String (Listof Symbol)))
(define (read-symbol-list str)
(cast (string->any (string-append "(" str ")")) (Listof Symbol)))
(module+ test
(test-case "read-symbol-list"
(check-equal? (read-symbol-list "a b c") '(a b c))))