Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View 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 "大势"
] <*>
["天地不仁仁者人也🐒话说天下大势分久必合🍑合久必分🔥"])