From e3efbb8f65ef75f645b462fbcf573983bc7b3948 Mon Sep 17 00:00:00 2001 From: Sergiu Ivanov Date: Sun, 6 Dec 2020 21:58:49 +0100 Subject: [PATCH] utils.rkt: Add handle-org-booleans. --- utils.rkt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/utils.rkt b/utils.rkt index dc80376..22ef972 100644 --- a/utils.rkt +++ b/utils.rkt @@ -160,3 +160,17 @@ (test-case "string->any" (check-equal? (string->any "(or b (not a))") '(or b (not a))) (check-equal? (string->any "14") 14))) + +;;; Given a sexp, converts all "#f" to #f and "#t" to #t. +;;; +;;; When I read Org-mode tables, I pump them through a call to the +;;; prin1 because the elisp sexp seems incompatible with Racket. On +;;; the other hand, Racket Booleans seem to upset elisp a little, so +;;; prin1 wraps them in additional double quotes. This function +;;; removes those quotes. +(: handle-org-booleans (-> Any Any)) +(define/match (handle-org-booleans datum) + [("#t") #t] + [("#f") #f] + [((? list?)) (map handle-org-booleans datum)] + [ (_) datum])