on master help sign in
Idris-dev/test/basic025/basic025.idr
28 lines 855 B history raw
1module basic025
3-- converting data from strings at runtime so as to prevent the
4-- compiler of eliding the calls to atan2 via constant folding
5input : List (String, String, String)
6input = [
7 ("atan2", " 1", " 1"),
8 ("atan2", "-1", " 1"),
9 ("atan2", " 1", "-1"),
10 ("atan2", "-1", "-1"),
11 ("atan2", " 0", " 1"),
12 ("atan2", " 1", " 0")
15round : Double -> Double
16round x = let y = x * 1e10
17 z = if y < 0 then (ceiling y) else (floor y)
18 in z / 1e10
20-- the input file is read at runtime so as to prevent the compiler of
21-- eliding the calls to atan2 via constant folding
22namespace Main
23 main : IO ()
24 main = traverse_ evalInput input
25 where
26 evalInput : (String, String, String) -> IO ()
27 evalInput ("atan2", y, x) = printLn $ round $ atan2 (cast y) (cast x)
28 evalInput _ = putStrLn $ "Could not eval line"