September Morn Update

This commit is contained in:
Ingy döt Net 2019-09-12 10:33:56 -07:00
parent 4e2d22a71d
commit aac6731f2c
6856 changed files with 141342 additions and 21127 deletions

View file

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