Update all new Tasks
This commit is contained in:
parent
00a190b0a6
commit
91df62d461
5697 changed files with 93386 additions and 804 deletions
12
Task/String-matching/Haskell/string-matching-1.hs
Normal file
12
Task/String-matching/Haskell/string-matching-1.hs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
> import Data.List
|
||||
> "abc" `isPrefixOf` "abcdefg"
|
||||
True
|
||||
> "efg" `isSuffixOf` "abcdefg"
|
||||
True
|
||||
> "bcd" `isInfixOf` "abcdefg"
|
||||
True
|
||||
> "abc" `isInfixOf` "abcdefg" -- Prefixes and suffixes are also infixes
|
||||
True
|
||||
> let infixes a b = findIndices (isPrefixOf a) $ tails b
|
||||
> infixes "ab" "abcdefabqqab"
|
||||
[0,6,10]
|
||||
10
Task/String-matching/Haskell/string-matching-2.hs
Normal file
10
Task/String-matching/Haskell/string-matching-2.hs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
procedure main()
|
||||
|
||||
write("Matching s2 :=",image(s2 := "ab")," within s1:= ",image(s1 := "abcdabab"))
|
||||
|
||||
write("Test #1 beginning ",if match(s2,s1) then "matches " else "failed")
|
||||
writes("Test #2 all matches at positions [")
|
||||
every writes(" ",find(s2,s1)|"]\n")
|
||||
write("Test #3 ending ", if s1[0-:*s2] == s2 then "matches" else "fails")
|
||||
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue