Next: strings rabin-karp, Previous: strings mutate, Up: strings [Index]
Replace the selected string in str1 with the selected string in str2. Return a newly allocated string.
Reverse the string. %string-reverse returns the result string
and does not alter its str parameter. %string-reverse! is
the in–place side–effecting variant.
Count the number of occurrences of words in the sequence returned by
successive invocations of getter-func, return a hashtable
associating words to counts. getter-func must return a Scheme
string at each invocation or #f when no more strings are
available.
(import (vicare)
(vicare containers strings)
(vicare containers char-sets))
(let* ((line "ciao ciao hello salut ciao salut")
(words (string-tokenize line char-set:ascii/letter))
(getter (let ((words words))
(lambda ()
(if (null? words)
#f
(begin0
(car words)
(set! words (cdr words)))))))
(result (word-frequency getter)))
(hashtable-ref result "ciao" 0) ⇒ 3
(hashtable-ref result "hello" 0) ⇒ 1
(hashtable-ref result "salut" 0)) ⇒ 2