diff options
author | Munyoki Kilyungi | 2023-08-23 17:03:56 +0300 |
---|---|---|
committer | Munyoki Kilyungi | 2023-08-23 17:03:56 +0300 |
commit | 200231f282c5e20a4dd1789adec070f87d437532 (patch) | |
tree | 935cd85af4f1fd2b0bb2a175ada29cbd849fdfc6 | |
parent | 4990ac117319ef7c7f2963cc8d3c0cbf1094ca86 (diff) | |
download | gn-transform-databases-200231f282c5e20a4dd1789adec070f87d437532.tar.gz |
Add extra utility fn for removing duplicates
Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
-rw-r--r-- | transform/strings.scm | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/transform/strings.scm b/transform/strings.scm index 98f828f..c7eb64a 100644 --- a/transform/strings.scm +++ b/transform/strings.scm @@ -10,6 +10,7 @@ string-split-substring delete-substrings replace-substrings + remove-duplicates sanitize-rdf-string snake->lower-camel string-capitalize-first)) @@ -99,3 +100,9 @@ association list mapping substrings to their replacements." (string-titlecase (string-downcase string) 0 1)) +(define (remove-duplicates lst) + (let loop ((lst lst) (result '())) + (cond + ((null? lst) (reverse result)) + ((memq (car lst) result) (loop (cdr lst) result)) + (else (loop (cdr lst) (cons (car lst) result)))))) |