From 49ffe09b4290ee3c1189660332fca51583c3916a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sun, 31 Mar 2019 00:12:00 +0100 Subject: Add as-{string,symb}. --- module/util.scm | 6 ++++++ module/vcalendar.scm | 9 ++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/module/util.scm b/module/util.scm index 82c2ddc0..2302f671 100644 --- a/module/util.scm +++ b/module/util.scm @@ -168,3 +168,9 @@ "Like @var{take}, but might lists shorter than length." (if (> i (length lst)) lst (take lst i))) + +(define-public (as-string s) + (if (symbol? s) (symbol->string s) s)) + +(define-public (as-symb s) + (if (string? s) (string->symbol s) s)) diff --git a/module/vcalendar.scm b/module/vcalendar.scm index bea9c0dc..51c4f8e3 100644 --- a/module/vcalendar.scm +++ b/module/vcalendar.scm @@ -31,13 +31,13 @@ (define (set-attr! component attr value) (%vcomponent-set-attribute! component - (if (symbol? attr) (symbol->string attr) attr) + (as-string attr) value)) (define (get-attr component attr) (%vcomponent-get-attribute component - (if (symbol? attr) (symbol->string attr) attr))) + (as-string attr))) ;; Enables symmetric get and set: ;; (set! (attr ev "KEY") 10) @@ -67,9 +67,8 @@ (cut get-attr <> field)) (define-public (key=? k1 k2) - (eq? - (if (string? k1) (string->symbol k1) k1) - (if (string? k2) (string->symbol k2) k2))) + (eq? (as-symb k1) + (as-symb k2))) (define* (make-vcomponent #:optional path) (if (not path) -- cgit v1.2.3