Skip to content

Commit 8f49da0

Browse files
committed
(#599) Get rid of T.last from MarkovMain
1 parent 8d0c84c commit 8f49da0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/MarkovMain.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,14 @@ import System.Environment
1313
import Text.InterpolatedString.QM
1414

1515
asteriskCorrectionFilter :: [T.Text] -> [T.Text]
16-
asteriskCorrectionFilter = filter ((/= '*') . T.last)
16+
asteriskCorrectionFilter = filter $ lastIsNot '*'
1717

1818
firstIsNot :: Char -> T.Text -> Bool
1919
firstIsNot x = maybe False ((/= x) . fst) . T.uncons
2020

21+
lastIsNot :: Char -> T.Text -> Bool
22+
lastIsNot x s = T.findIndex (== x) s /= Just (T.length s - 1)
23+
2124
mentionsFilter :: [T.Text] -> [T.Text]
2225
mentionsFilter =
2326
filter (not . T.null) . map (T.unwords . filter (firstIsNot '@') . T.words)

0 commit comments

Comments
 (0)