1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
-- !!! test quot/rem/div/mod functions on Ints and Integers
--
main
= putStr
(-- w/ Ints and Integers
show (unzipWith div ints_list)
++ "\n"
++ show (unzipWith div integers_list)
++ "\n"
++ show (unzipWith rem ints_list)
++ "\n"
++ show (unzipWith rem integers_list)
++ "\n"
++ show (unzipWith quot ints_list)
++ "\n"
++ show (unzipWith quot integers_list)
++ "\n"
++ show (unzipWith mod ints_list)
++ "\n"
++ show (unzipWith mod integers_list)
++ "\n"
++ show (unzipWith law1 ints_list)
++ "\n"
++ show (unzipWith law1 integers_list)
++ "\n"
++ show (unzipWith law2 ints_list)
++ "\n"
++ show (unzipWith law2 integers_list)
++ "\n"
)
where
ints_list :: [(Int, Int)]
integers_list :: [(Integer, Integer)]
ints_list = [
(0, 4),
(0, -8),
(7, 3),
(13, 4),
(13, -4),
(-13, 4),
(-13, -4),
(12345678, 10000),
(12345678, -10000),
(-12345678, 10000),
(-12345678, -10000),
(123456,10000),
(1234567,20000),
(12345678,-10000),
(123456789,10000),
(1234567890,-10000),
(-12345,10000),
(-123456789,-10000)
]
integers_list = [
(0, 4),
(0, -8),
(7, 3),
(13, 4),
(13, -4),
(-13, 4),
(-13, -4),
(12345678, 10000),
(12345678, -10000),
(-12345678, 10000),
(-12345678, -10000),
(123456,10000),
(1234567,20000),
(12345678,-10000),
(123456789,10000),
(1234567890,-10000),
(-12345,10000),
(-123456789,-10000),
(12345678900,500000000),
(1234000000000000000000005678900,5001111111111111000000)
]
unzipWith :: (a -> b -> c) -> [(a,b)] -> [c]
unzipWith f [] = []
unzipWith f ((x,y):zs) = f x y : unzipWith f zs
law1, law2 :: Integral a => a -> a -> Bool
law1 x y = (x `quot` y)*y + (x `rem` y) == x
law2 x y = (x `div` y)*y + (x `mod` y) == x
|