Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
18
Task/String-matching/Wren/string-matching.wren
Normal file
18
Task/String-matching/Wren/string-matching.wren
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
var s = "abracadabra"
|
||||
var t = "abra"
|
||||
var u = "ra"
|
||||
var v = "cad"
|
||||
System.print("'%(s)' starts with '%(t)' is %(s.startsWith(t))")
|
||||
var indices = []
|
||||
var start = 0
|
||||
while (true) {
|
||||
var ix = s.indexOf(u, start)
|
||||
if (ix >= 0) {
|
||||
indices.add(ix)
|
||||
start = ix + u.count
|
||||
if (start >= s.count) break
|
||||
} else break
|
||||
}
|
||||
var contained = indices.count > 0
|
||||
System.print("'%(s)' contains '%(u)' is %(contained) %(contained ? "at indices %(indices)" : "")")
|
||||
System.print("'%(s)' ends with '%(v)' is %(s.endsWith(v))")
|
||||
Loading…
Add table
Add a link
Reference in a new issue