rs: Add read-ctx and illustrate it in example.org.
This commit is contained in:
parent
171147ad5e
commit
c0d36a34a7
2 changed files with 20 additions and 1 deletions
|
@ -519,6 +519,22 @@ tab
|
|||
- a
|
||||
- b
|
||||
|
||||
You can also give a name to a list and read it with =munch-sexp=:
|
||||
|
||||
#+NAME: ctx1
|
||||
- x y
|
||||
- z
|
||||
-
|
||||
- t
|
||||
|
||||
#+BEGIN_SRC racket :results output drawer :var input-ctx=munch-sexp(ctx1)
|
||||
(read-ctx input-ctx)
|
||||
#+END_SRC
|
||||
|
||||
#+RESULTS:
|
||||
:RESULTS:
|
||||
(list (set 'x 'y) (set 'z) (set) (set 't))
|
||||
:END:
|
||||
|
||||
* Local Variables :noexport:
|
||||
# Local Variables:
|
||||
|
|
5
rs.rkt
5
rs.rkt
|
@ -31,7 +31,7 @@
|
|||
;; Contracts
|
||||
(contract-out [reaction-system/c contract?])
|
||||
;; Syntax
|
||||
unorg-rs org-rs)
|
||||
unorg-rs org-rs read-ctx)
|
||||
|
||||
;;; =================
|
||||
;;; Basic definitions
|
||||
|
@ -107,6 +107,9 @@
|
|||
(define (read-context-sequence str)
|
||||
(map (compose list->set read-symbol-list) (flatten (read-org-sexp str))))
|
||||
|
||||
;;; A shortcut to read-context-sequence.
|
||||
(define-syntax-rule (read-ctx str) (read-context-sequence str))
|
||||
|
||||
;;; Removes the first and the last symbol of a given string.
|
||||
(define (drop-first-last str)
|
||||
(substring str 1 (- (string-length str) 1)))
|
||||
|
|
Loading…
Reference in a new issue