Implement set equality.

This commit is contained in:
Dominik Pantůček 2023-04-11 13:49:28 +02:00
parent 30664d10f8
commit 575c1cdb3d
7 changed files with 44 additions and 7 deletions

View file

@ -30,6 +30,7 @@
(
string-repeat
string-first+rest
string-utf8?
)
(import scheme
@ -57,6 +58,12 @@
(val (irregex-replace (irregex "^[ \\t]*" 'u) sep+val "")))
(cons key-str val))
(cons str ""))))
;; Returns true, if given string contains UTF-8 characters
(define (string-utf8? str)
(let ((asciilen (string-length str))
(utf8len (length (irregex-extract (irregex "." 'u)))))
(not (= asciilen utf8len))))
;; Performs utils module self-tests.
(define (utils-tests!)
@ -77,6 +84,8 @@
(test-equal? string-first+rest
(string-first+rest "asdf")
'("asdf" . ""))
(test-true string-utf8? (string-utf8? "ěščř"))
(test-false string-utf8? (string-utf8? "Hello World!"))
))
)