Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1 @@
|
|||
((show :: Integer -> String) . succ . read) "1234"
|
||||
|
|
@ -0,0 +1 @@
|
|||
((show :: Bool -> String) . succ . read) "False"
|
||||
|
|
@ -0,0 +1 @@
|
|||
(show . (+1) . read) "1234"
|
||||
|
|
@ -0,0 +1 @@
|
|||
(show . succ) (read "1234" :: Int)
|
||||
|
|
@ -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"
|
||||
Loading…
Add table
Add a link
Reference in a new issue