Update all new Tasks
This commit is contained in:
parent
00a190b0a6
commit
91df62d461
5697 changed files with 93386 additions and 804 deletions
31
Task/String-matching/Maple/string-matching.maple
Normal file
31
Task/String-matching/Maple/string-matching.maple
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
> with( StringTools ): # bind package exports at the top-level
|
||||
> s := "dzrIemaWWIMidXYZwGiqkOOn":
|
||||
> s[1..4]; # pick a prefix
|
||||
"dzrI"
|
||||
|
||||
> IsPrefix( s[ 1 .. 4 ], s ); # check it
|
||||
true
|
||||
|
||||
> s[ -4 .. -1 ]; # pick a suffix
|
||||
"kOOn"
|
||||
|
||||
> IsSuffix( s[ -4 .. -1 ], s ); # check it
|
||||
true
|
||||
|
||||
> p := Search( "XYZ", s ); # find a substring
|
||||
p := 14
|
||||
|
||||
> s[ p .. p + 2 ]; # check
|
||||
"XYZ"
|
||||
|
||||
> SearchAll( [ "WWI", "XYZ" ], s ); # search for multiple patterns
|
||||
[8, 1], [14, 2]
|
||||
|
||||
> to 3 do s := cat( s, s ) end: length( s ); # build a longer string by repeated doubling
|
||||
192
|
||||
|
||||
> p := SearchAll( "XYZ", s ); # find all occurrences
|
||||
p := 14, 38, 62, 86, 110, 134, 158, 182
|
||||
|
||||
> {seq}( s[ i .. i + 2 ], i = p ); # check them
|
||||
{"XYZ"}
|
||||
Loading…
Add table
Add a link
Reference in a new issue