diff --git a/utils-tests.rkt b/utils-tests.rkt index 3d075d5..bb4be65 100644 --- a/utils-tests.rkt +++ b/utils-tests.rkt @@ -45,4 +45,6 @@ (check-equal? (hash-ref mp 'a) "(and a 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 "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))")))) diff --git a/utils.rkt b/utils.rkt index d4c3bac..3c736c7 100644 --- a/utils.rkt +++ b/utils.rkt @@ -13,7 +13,8 @@ [extract-symbols (-> any/c list?)] [any->string (-> any/c string?)] [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 (contract-out [variable-mapping? contract?] [string-variable-mapping? contract?]) @@ -167,3 +168,7 @@ ;;; Reads any value from string. (define (string->any str) (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))