From 5545a02c149469c094692fd592064fcec3fc7a67 Mon Sep 17 00:00:00 2001 From: Munyoki Kilyungi Date: Mon, 10 Jul 2023 12:22:29 +0300 Subject: Pass port as an optional argument * dump/triples.scm (triple): Add port as an optional argument. Defaults to #t. This enables us to use triple to print to other ports E.g in the case of dumping documentation to a different file. Signed-off-by: Munyoki Kilyungi --- dump/triples.scm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dump/triples.scm b/dump/triples.scm index a0f8213..19817bd 100644 --- a/dump/triples.scm +++ b/dump/triples.scm @@ -44,7 +44,9 @@ characters with an underscore and prefixing with gn:PREFIX." (string->symbol `,(format #f "~a~a" prefix value)))) -(define (triple subject predicate object) +(define* (triple subject predicate object + #:optional + (port #t)) (unless (or (string? subject) (symbol? subject)) (error "Triple subject not a string or symbol:" @@ -63,7 +65,7 @@ characters with an underscore and prefixing with gn:PREFIX." (? (lambda (el) (string-match "^\\[ .* \\]$" el)) object)) "~a ~a ~a .~%") (_ "~a ~a \"~a\" .~%"))]) - (format #t pattern subject predicate + (format port pattern subject predicate (if (symbol? object) (symbol->string object) object)))) (define (scm->triples alist id) -- cgit v1.2.3