Idris2/benchmark/benchmarks/mergeStr/mergeStr.idr

26 lines
716 B
Idris
Raw Normal View History

2021-01-12 16:22:58 +03:00
import System.File
import Data.String
2021-01-12 16:22:58 +03:00
import Data.List
-- read in a dictionary, shuffle and then resort
mylast : List a -> Maybe a
mylast [] = Nothing
mylast [x] = Just x
mylast (x::xs) = mylast xs
doSort : Nat -> IO ()
doSort Z = putStrLn "Done"
doSort (S k) = do Right dict<-readFile "words"
| Left err => putStrLn $ show err
-- reverse and get last word
let xs = reverse $ words dict
putStrLn $ show $ mylast xs
-- sort reversed list and get last word
putStrLn $ show $ mylast $ sort xs
doSort k
2021-01-16 17:26:55 +03:00
2021-01-12 16:22:58 +03:00
main : IO ()
main = do max <- getLine
doSort (integerToNat (cast max))