September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -0,0 +1,30 @@
import qualified Data.Text as T
(Text, take, drop, init, breakOn, pack, unpack)
fromNforM :: Int -> Int -> T.Text -> T.Text
fromNforM 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
fromCharForM :: T.Text -> Int -> T.Text -> T.Text
fromCharForM needle m haystack = T.take m $ snd (T.breakOn needle haystack)
fromStringForM :: T.Text -> Int -> T.Text -> T.Text
fromStringForM = fromCharForM
-- TEST -----------------------------------------------------------------------
main :: IO ()
main =
mapM_
(putStrLn . T.unpack)
([ fromNforM 9 10
, fromNtoEnd 20
, allButLast
, fromCharForM (T.pack "") 6
, fromStringForM (T.pack "大势") 6
] <*>
[T.pack "天地不仁仁者人也🐒话说天下大势分久必合🍑合久必分🔥"])