blob: 12ca7413f15581bb2af1e449b9f0eebc53ce6788 (
plain)
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
{-# OPTIONS -fno-implicit-prelude #-}
module Test18 where
import PrelGHC
import PrelBase
eftCharFB c n x y = go x
where
go x | x ># y = n
| otherwise = C# (chr# x) `c` go (x +# 1#)
eftIntFB c n x y | x ># y = n
| otherwise = go x
where
go x = I# x `c` if x ==# y then n else go (x +# 1#)
eftIntList x y | x ># y = []
| otherwise = go x
where
go x = I# x : if x ==# y then [] else go (x +# 1#)
efdCharFB c n x1 x2
| delta >=# 0# = go_up_char_fb c n x1 delta 255#
| otherwise = go_dn_char_fb c n x1 delta 0#
where
delta = x2 -# x1
efdCharList x1 x2
| delta >=# 0# = go_up_char_list x1 delta 255#
| otherwise = go_dn_char_list x1 delta 0#
where
delta = x2 -# x1
efdtCharFB c n x1 x2 lim
| delta >=# 0# = go_up_char_fb c n x1 delta lim
| otherwise = go_dn_char_fb c n x1 delta lim
where
delta = x2 -# x1
efdtCharList x1 x2 lim
| delta >=# 0# = go_up_char_list x1 delta lim
| otherwise = go_dn_char_list x1 delta lim
where
delta = x2 -# x1
go_up_char_fb c n x delta lim
= go_up x
where
go_up x | x ># lim = n
| otherwise = C# (chr# x) `c` go_up (x +# delta)
go_dn_char_fb c n x delta lim
= go_dn x
where
go_dn x | x <# lim = n
| otherwise = C# (chr# x) `c` go_dn (x +# delta)
go_up_char_list x delta lim
= go_up x
where
go_up x | x ># lim = []
| otherwise = C# (chr# x) : go_up (x +# delta)
go_dn_char_list x delta lim
= go_dn x
where
go_dn x | x <# lim = []
| otherwise = C# (chr# x) : go_dn (x +# delta)
efdtIntFB c n x1 x2 y
| delta >=# 0# = if x1 ># y then n else go_up_int_fb c n x1 delta lim
| otherwise = if x1 <# y then n else go_dn_int_fb c n x1 delta lim
where
delta = x2 -# x1
lim = y -# delta
efdtIntList x1 x2 y
| delta >=# 0# = if x1 ># y then [] else go_up_int_list x1 delta lim
| otherwise = if x1 <# y then [] else go_dn_int_list x1 delta lim
where
delta = x2 -# x1
lim = y -# delta
efdIntFB c n x1 x2
| delta >=# 0# = go_up_int_fb c n x1 delta ( 2147483647# -# delta)
| otherwise = go_dn_int_fb c n x1 delta ((-2147483648#) -# delta)
where
delta = x2 -# x1
efdIntList x1 x2
| delta >=# 0# = go_up_int_list x1 delta ( 2147483647# -# delta)
| otherwise = go_dn_int_list x1 delta ((-2147483648#) -# delta)
where
delta = x2 -# x1
-- In all of these, the (x +# delta) is guaranteed not to overflow
go_up_int_fb c n x delta lim
= go_up x
where
go_up x | x ># lim = I# x `c` n
| otherwise = I# x `c` go_up (x +# delta)
go_dn_int_fb c n x delta lim
= go_dn x
where
go_dn x | x <# lim = I# x `c` n
| otherwise = I# x `c` go_dn (x +# delta)
go_up_int_list x delta lim
= go_up x
where
go_up x | x ># lim = [I# x]
| otherwise = I# x : go_up (x +# delta)
go_dn_int_list x delta lim
= go_dn x
where
go_dn x | x <# lim = [I# x]
| otherwise = I# x : go_dn (x +# delta)
eftInt = eftIntList
efdInt = efdIntList
efdtInt = efdtIntList
|