about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ravanan/work/utils.scm8
1 files changed, 7 insertions, 1 deletions
diff --git a/ravanan/work/utils.scm b/ravanan/work/utils.scm
index 5e057e3..df1cf21 100644
--- a/ravanan/work/utils.scm
+++ b/ravanan/work/utils.scm
@@ -27,7 +27,8 @@
   #:use-module (system foreign)
   #:use-module (system foreign-library)
   #:use-module (ravanan work vectors)
-  #:export (list->dotted-list
+  #:export (string-remove-prefix
+            list->dotted-list
             alist=?
             assoc-ref*
             assoc-set
@@ -37,6 +38,11 @@
             call-with-input-pipe
             call-with-atomic-output-file))
 
+(define (string-remove-prefix prefix str)
+  "Remove @var{prefix} from @var{str}, if present. Else, return @code{#f}."
+  (and (string-prefix? prefix str)
+       (substring str (string-length prefix))))
+
 (define (list->dotted-list lst)
   "Convert @var{lst} of 2-element lists into a true association list of
 pairs."