mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-24 20:23:11 +03:00
c34c6e0959
- Fix off-by-one error in String reverse - Correct order of arguments in strSubstr - Actually use start index of strSubstr - Reduce memory usage of strSubstr in case of overrunning string end - Add fastPack/fastUnpack/fastConcat - Use unsigned chars for character comparisons - Fix generated C character encodings
33 lines
908 B
Idris
33 lines
908 B
Idris
module TestStrings
|
|
|
|
import Data.String
|
|
|
|
main : IO ()
|
|
main = do
|
|
let helloWorld = "Hello, " ++ "world"
|
|
|
|
putStrLn helloWorld
|
|
putStrLn $ show $ length helloWorld
|
|
|
|
putStrLn $ reverse helloWorld
|
|
putStrLn $ substr 1 2 helloWorld
|
|
putStrLn $ show $ assert_total $ strIndex helloWorld 1
|
|
|
|
putStrLn $ strCons 'a' "bc"
|
|
putStrLn $ show $ strUncons "abc"
|
|
|
|
putStrLn $ fastPack ['p', 'a', 'c', 'k']
|
|
putStrLn $ show $ fastUnpack "unpack"
|
|
putStrLn $ fastConcat ["con", "cat", "en", "ate"]
|
|
|
|
let chars = ['a', 'A', '~', '0', ' ', '\n', '\x9f']
|
|
putStrLn $ show $ map isUpper chars
|
|
putStrLn $ show $ map isLower chars
|
|
putStrLn $ show $ map isDigit chars
|
|
putStrLn $ show $ map isSpace chars
|
|
putStrLn $ show $ map isNL chars
|
|
putStrLn $ show $ map isControl chars
|
|
|
|
putStrLn $ show $ map chr [97, 65, 126, 48, 32, 10, 159]
|
|
putStrLn $ show $ map ord chars
|