22 lines
740 B
Text
22 lines
740 B
Text
with javascript_semantics
|
|
constant sentence = "abracadabra", w1 = "abra", w2 = "bar",
|
|
fmt = """
|
|
For the string "%s":
|
|
1: Starts with "%s": %t.
|
|
Starts with "%s": %t.
|
|
2: Contains "%s": %t%s.
|
|
Contains "%s": %t%s.
|
|
3: Ends with "%s": %t.
|
|
Ends with "%s": %t.
|
|
"""
|
|
function jma(string word, sentence)
|
|
sequence r = match_all(word,sentence)
|
|
return iff(r={} ? "" : ", at "&join(r,", ", " and ","%d"))
|
|
end function
|
|
|
|
printf(1,fmt,{sentence,w1,begins(w1,sentence),
|
|
w2,begins(w2,sentence),
|
|
w1,match(w1,sentence),jma(w1,sentence),
|
|
w2,match(w2,sentence),jma(w2,sentence),
|
|
w1,ends(w1,sentence),
|
|
w2,ends(w2,sentence)})
|