utils: Generalise unstringify-pairs to accept both proper and improper pairs.
This commit is contained in:
parent
5b4d39a1b0
commit
a2b8df2a67
1 changed files with 6 additions and 3 deletions
|
@ -15,7 +15,7 @@
|
|||
[stringify-variable-mapping (-> variable-mapping? string-variable-mapping?)]
|
||||
[string->any (-> string? any/c)]
|
||||
[read-org-table (-> string? (listof any/c))]
|
||||
[unstringify-pairs (-> (listof (cons/c string? string?)) (listof (cons/c symbol? any/c)))])
|
||||
[unstringify-pairs (-> (listof (list/c string? string?)) (listof (list/c symbol? any/c)))])
|
||||
;; Contracts
|
||||
(contract-out [variable-mapping? contract?]
|
||||
[string-variable-mapping? contract?])
|
||||
|
@ -179,5 +179,8 @@
|
|||
;;; string->any.
|
||||
(define (unstringify-pairs pairs)
|
||||
(for/list ([p pairs])
|
||||
(match-let ([(cons key val) p])
|
||||
(cons (string->symbol key) (string->any val)))))
|
||||
(match p
|
||||
[(list key val)
|
||||
(cons (string->symbol key) (string->any val))]
|
||||
[(cons key val) ; also handle improper pairs
|
||||
(cons (string->symbol key) (string->any val))])))
|
||||
|
|
Loading…
Reference in a new issue