aboutsummaryrefslogtreecommitdiff
path: root/dump
diff options
context:
space:
mode:
authorMunyoki Kilyungi2023-04-05 15:58:11 +0300
committerBonfaceKilz2023-04-05 16:17:11 +0300
commit3d7daabfaed706d44f5e174b912ad25b0f95fbb2 (patch)
treee18498b8fc88cb20ac53cebbd27ecda5d248af6a /dump
parent18f3d6b2635fba32cc7b522550f2485613f7e863 (diff)
downloadgn-transform-databases-3d7daabfaed706d44f5e174b912ad25b0f95fbb2.tar.gz
Simplify pattern matching when checking for a node
Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
Diffstat (limited to 'dump')
-rw-r--r--dump/triples.scm17
1 files changed, 7 insertions, 10 deletions
diff --git a/dump/triples.scm b/dump/triples.scm
index 1f2ab87..8ed9952 100644
--- a/dump/triples.scm
+++ b/dump/triples.scm
@@ -41,16 +41,13 @@ characters with an underscore and prefixing with gn:PREFIX."
(number? object))
(error "Triple object not a string, symbol or number:"
(list subject predicate object)))
- (match object
- ((and (? string? object)
- (? (lambda (el) (string-match "^\\[ .* \\]$" object))))
- (format #t "~a ~a ~a .~%" subject predicate object))
- ((? symbol? object)
- (format #t "~a ~a ~a .~%" subject predicate object))
- ((or (? string? object)
- (? number? object))
- (format #t "~a ~a ~s .~%" subject predicate object))
- (_ (error "Trible object must be a string, symbol, number or blank node"))))
+ (let ([pattern (match object
+ ((or (? symbol? object)
+ ;; Check for a node
+ (? (lambda (el) (string-match "^\\[ .* \\]$" el)) object))
+ "~a ~a ~a .~%")
+ (_ "~a ~a ~s .~%"))])
+ (format #t pattern subject predicate object)))
(define (scm->triples alist id)
(for-each (match-lambda