Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
3
Task/Substring/Haskell/substring-1.hs
Normal file
3
Task/Substring/Haskell/substring-1.hs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
t45 n c s | null sub = []
|
||||
| otherwise = take n. head $ sub
|
||||
where sub = filter(isPrefixOf c) $ tails s
|
||||
31
Task/Substring/Haskell/substring-2.hs
Normal file
31
Task/Substring/Haskell/substring-2.hs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
import qualified Data.Text as T (Text, take, drop, init, breakOn)
|
||||
import qualified Data.Text.IO as O (putStrLn)
|
||||
|
||||
fromMforN :: Int -> Int -> T.Text -> T.Text
|
||||
fromMforN n m s = T.take m (T.drop n s)
|
||||
|
||||
fromNtoEnd :: Int -> T.Text -> T.Text
|
||||
fromNtoEnd = T.drop
|
||||
|
||||
allButLast :: T.Text -> T.Text
|
||||
allButLast = T.init
|
||||
|
||||
fromCharForN, fromStringForN :: Int -> T.Text -> T.Text -> T.Text
|
||||
fromCharForN m needle haystack = T.take m $ snd $ T.breakOn needle haystack
|
||||
|
||||
fromStringForN = fromCharForN
|
||||
|
||||
-- TEST ---------------------------------------------------
|
||||
main :: IO ()
|
||||
main =
|
||||
mapM_
|
||||
O.putStrLn
|
||||
([ fromMforN 9 10
|
||||
, fromNtoEnd 20
|
||||
, allButLast
|
||||
, fromCharForN 6 "话"
|
||||
, fromStringForN 6 "大势"
|
||||
] <*>
|
||||
["天地不仁仁者人也🐒话说天下大势分久必合🍑合久必分🔥"])
|
||||
Loading…
Add table
Add a link
Reference in a new issue