mirror of
https://github.com/carp-lang/Carp.git
synced 2024-11-05 04:44:12 +03:00
Merge pull request #973 from jacereda/fix-suffix
Fix suffix docs and implementation, simplify prefix.
This commit is contained in:
commit
2f302aa046
@ -79,11 +79,11 @@
|
||||
|
||||
(doc prefix "Return the first `a` characters of the string `s`.")
|
||||
(defn prefix [s a]
|
||||
(from-chars &(Array.slice &(chars s) 0 a)))
|
||||
(from-chars &(Array.prefix &(chars s) a)))
|
||||
|
||||
(doc suffix "Return the last `b` characters of the string `s`.")
|
||||
(doc suffix "Returns the suffix string starting at the `b`th character.")
|
||||
(defn suffix [s b]
|
||||
(from-chars &(Array.slice &(chars s) b (length s))))
|
||||
(from-chars &(Array.suffix &(chars s) b)))
|
||||
|
||||
(doc starts-with? "Check if the string `s` begins with the string `sub`.")
|
||||
(defn starts-with? [s sub]
|
||||
|
@ -94,6 +94,10 @@
|
||||
"dang"
|
||||
&(suffix "svedang" 3)
|
||||
"suffix works as expected")
|
||||
(assert-equal test
|
||||
"😲😲😲😲"
|
||||
&(suffix "😲😲😲😲😲" 1)
|
||||
"suffix works as expected II")
|
||||
(assert-true test
|
||||
(ends-with? "heller" "ler")
|
||||
"ends-with? works as expected")
|
||||
|
Loading…
Reference in New Issue
Block a user