diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2019-03-31 00:12:00 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2019-03-31 00:12:00 +0100 |
commit | 49ffe09b4290ee3c1189660332fca51583c3916a (patch) | |
tree | 80fc507b6c231fd820092752086b9400788d2d3e | |
parent | Add cval field to LLIST. (diff) | |
download | calp-49ffe09b4290ee3c1189660332fca51583c3916a.tar.gz calp-49ffe09b4290ee3c1189660332fca51583c3916a.tar.xz |
Add as-{string,symb}.
Diffstat (limited to '')
-rw-r--r-- | module/util.scm | 6 | ||||
-rw-r--r-- | 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) |