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 @@
((show :: Integer -> String) . succ . read) "1234"

View file

@ -0,0 +1 @@
((show :: Bool -> String) . succ . read) "False"

View file

@ -0,0 +1 @@
(show . (+1) . read) "1234"

View file

@ -0,0 +1 @@
(show . succ) (read "1234" :: Int)

View file

@ -0,0 +1,30 @@
import Text.Read (readMaybe)
import Data.Maybe (mapMaybe)
succString :: Bool -> String -> String
succString pruned s =
let succs
:: (Num a, Show a)
=> a -> Maybe String
succs = Just . show . (1 +)
go w
| elem '.' w = (readMaybe w :: Maybe Double) >>= succs
| otherwise = (readMaybe w :: Maybe Integer) >>= succs
opt w
| pruned = Nothing
| otherwise = Just w
in unwords $
mapMaybe
(\w ->
case go w of
Just s -> Just s
_ -> opt w)
(words s)
-- TEST ---------------------------------------------------
main :: IO ()
main =
(putStrLn . unlines) $
succString <$> [True, False] <*>
pure "41.0 pine martens in 1491 -1.5 mushrooms ≠ 136"