Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,23 @@
assert "abcd".startsWith("ab")
assert ! "abcd".startsWith("zn")
assert "abcd".endsWith("cd")
assert ! "abcd".endsWith("zn")
assert "abab".contains("ba")
assert ! "abab".contains("bb")
assert "abab".indexOf("bb") == -1 // not found flag
assert "abab".indexOf("ab") == 0
def indicesOf = { string, substring ->
if (!string) { return [] }
def indices = [-1]
while (true) {
indices << string.indexOf(substring, indices.last()+1)
if (indices.last() == -1) break
}
indices[1..<(indices.size()-1)]
}
assert indicesOf("abab", "ab") == [0, 2]
assert indicesOf("abab", "ba") == [1]
assert indicesOf("abab", "xy") == []