utils: Add read-org-table.
This commit is contained in:
parent
7d52533f74
commit
fed1f65abd
2 changed files with 9 additions and 2 deletions
|
@ -45,4 +45,6 @@
|
||||||
(check-equal? (hash-ref mp 'a) "(and a b)")
|
(check-equal? (hash-ref mp 'a) "(and a b)")
|
||||||
(check-equal? (hash-ref mp 'b) "(not b)"))
|
(check-equal? (hash-ref mp 'b) "(not b)"))
|
||||||
(check-equal? (string->any "(or b (not a))") '(or b (not a)))
|
(check-equal? (string->any "(or b (not a))") '(or b (not a)))
|
||||||
(check-equal? (string->any "14") 14))
|
(check-equal? (string->any "14") 14)
|
||||||
|
(check-equal? (read-org-table "((\"a\" \"(and a b)\") (\"b\" \"(or b (not a))\"))")
|
||||||
|
'(("a" "(and a b)") ("b" "(or b (not a))"))))
|
||||||
|
|
|
@ -13,7 +13,8 @@
|
||||||
[extract-symbols (-> any/c list?)]
|
[extract-symbols (-> any/c list?)]
|
||||||
[any->string (-> any/c string?)]
|
[any->string (-> any/c string?)]
|
||||||
[stringify-variable-mapping (-> variable-mapping? string-variable-mapping?)]
|
[stringify-variable-mapping (-> variable-mapping? string-variable-mapping?)]
|
||||||
[string->any (-> string? any/c)])
|
[string->any (-> string? any/c)]
|
||||||
|
[read-org-table (-> string? (listof any/c))])
|
||||||
;; Contracts
|
;; Contracts
|
||||||
(contract-out [variable-mapping? contract?]
|
(contract-out [variable-mapping? contract?]
|
||||||
[string-variable-mapping? contract?])
|
[string-variable-mapping? contract?])
|
||||||
|
@ -167,3 +168,7 @@
|
||||||
;;; Reads any value from string.
|
;;; Reads any value from string.
|
||||||
(define (string->any str)
|
(define (string->any str)
|
||||||
(with-input-from-string str (λ () (read))))
|
(with-input-from-string str (λ () (read))))
|
||||||
|
|
||||||
|
;;; Reads a table from a string produced by Org-mode for a named
|
||||||
|
;;; table. See example.org for examples.
|
||||||
|
(define (read-org-table str) (string->any str))
|
||||||
|
|
Loading…
Reference in a new issue