ic-mops 0.8.5 → 0.8.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -1
- package/.mops/base@0.7.4/LICENSE +0 -208
- package/.mops/base@0.7.4/README.md +0 -64
- package/.mops/base@0.7.4/mops.toml +0 -5
- package/.mops/base@0.7.4/src/Array.mo +0 -686
- package/.mops/base@0.7.4/src/AssocList.mo +0 -203
- package/.mops/base@0.7.4/src/Blob.mo +0 -55
- package/.mops/base@0.7.4/src/Bool.mo +0 -44
- package/.mops/base@0.7.4/src/Buffer.mo +0 -1937
- package/.mops/base@0.7.4/src/CertifiedData.mo +0 -29
- package/.mops/base@0.7.4/src/Char.mo +0 -67
- package/.mops/base@0.7.4/src/Debug.mo +0 -15
- package/.mops/base@0.7.4/src/Deque.mo +0 -75
- package/.mops/base@0.7.4/src/Error.mo +0 -41
- package/.mops/base@0.7.4/src/ExperimentalCycles.mo +0 -51
- package/.mops/base@0.7.4/src/ExperimentalInternetComputer.mo +0 -36
- package/.mops/base@0.7.4/src/ExperimentalStableMemory.mo +0 -121
- package/.mops/base@0.7.4/src/Float.mo +0 -150
- package/.mops/base@0.7.4/src/Func.mo +0 -38
- package/.mops/base@0.7.4/src/Hash.mo +0 -83
- package/.mops/base@0.7.4/src/HashMap.mo +0 -229
- package/.mops/base@0.7.4/src/Heap.mo +0 -113
- package/.mops/base@0.7.4/src/Int.mo +0 -150
- package/.mops/base@0.7.4/src/Int16.mo +0 -159
- package/.mops/base@0.7.4/src/Int32.mo +0 -160
- package/.mops/base@0.7.4/src/Int64.mo +0 -161
- package/.mops/base@0.7.4/src/Int8.mo +0 -160
- package/.mops/base@0.7.4/src/Iter.mo +0 -220
- package/.mops/base@0.7.4/src/IterType.mo +0 -7
- package/.mops/base@0.7.4/src/List.mo +0 -433
- package/.mops/base@0.7.4/src/Nat.mo +0 -75
- package/.mops/base@0.7.4/src/Nat16.mo +0 -146
- package/.mops/base@0.7.4/src/Nat32.mo +0 -146
- package/.mops/base@0.7.4/src/Nat64.mo +0 -146
- package/.mops/base@0.7.4/src/Nat8.mo +0 -146
- package/.mops/base@0.7.4/src/None.mo +0 -19
- package/.mops/base@0.7.4/src/Option.mo +0 -160
- package/.mops/base@0.7.4/src/Order.mo +0 -46
- package/.mops/base@0.7.4/src/Prelude.mo +0 -33
- package/.mops/base@0.7.4/src/Principal.mo +0 -58
- package/.mops/base@0.7.4/src/RBTree.mo +0 -218
- package/.mops/base@0.7.4/src/Random.mo +0 -188
- package/.mops/base@0.7.4/src/Result.mo +0 -210
- package/.mops/base@0.7.4/src/Stack.mo +0 -40
- package/.mops/base@0.7.4/src/Text.mo +0 -615
- package/.mops/base@0.7.4/src/Time.mo +0 -37
- package/.mops/base@0.7.4/src/Trie.mo +0 -1200
- package/.mops/base@0.7.4/src/TrieMap.mo +0 -180
- package/.mops/base@0.7.4/src/TrieSet.mo +0 -97
- package/.mops/base@0.8.3/LICENSE +0 -208
- package/.mops/base@0.8.3/README.md +0 -64
- package/.mops/base@0.8.3/mops.toml +0 -6
- package/.mops/base@0.8.3/src/Array.mo +0 -717
- package/.mops/base@0.8.3/src/AssocList.mo +0 -404
- package/.mops/base@0.8.3/src/Blob.mo +0 -212
- package/.mops/base@0.8.3/src/Bool.mo +0 -44
- package/.mops/base@0.8.3/src/Buffer.mo +0 -2660
- package/.mops/base@0.8.3/src/CertifiedData.mo +0 -53
- package/.mops/base@0.8.3/src/Char.mo +0 -65
- package/.mops/base@0.8.3/src/Debug.mo +0 -56
- package/.mops/base@0.8.3/src/Deque.mo +0 -243
- package/.mops/base@0.8.3/src/Error.mo +0 -68
- package/.mops/base@0.8.3/src/ExperimentalCycles.mo +0 -151
- package/.mops/base@0.8.3/src/ExperimentalInternetComputer.mo +0 -60
- package/.mops/base@0.8.3/src/ExperimentalStableMemory.mo +0 -348
- package/.mops/base@0.8.3/src/Float.mo +0 -843
- package/.mops/base@0.8.3/src/Func.mo +0 -46
- package/.mops/base@0.8.3/src/Hash.mo +0 -82
- package/.mops/base@0.8.3/src/HashMap.mo +0 -457
- package/.mops/base@0.8.3/src/Heap.mo +0 -233
- package/.mops/base@0.8.3/src/Int.mo +0 -365
- package/.mops/base@0.8.3/src/Int16.mo +0 -521
- package/.mops/base@0.8.3/src/Int32.mo +0 -522
- package/.mops/base@0.8.3/src/Int64.mo +0 -522
- package/.mops/base@0.8.3/src/Int8.mo +0 -522
- package/.mops/base@0.8.3/src/Iter.mo +0 -227
- package/.mops/base@0.8.3/src/IterType.mo +0 -7
- package/.mops/base@0.8.3/src/List.mo +0 -930
- package/.mops/base@0.8.3/src/Nat.mo +0 -305
- package/.mops/base@0.8.3/src/Nat16.mo +0 -144
- package/.mops/base@0.8.3/src/Nat32.mo +0 -144
- package/.mops/base@0.8.3/src/Nat64.mo +0 -144
- package/.mops/base@0.8.3/src/Nat8.mo +0 -144
- package/.mops/base@0.8.3/src/None.mo +0 -19
- package/.mops/base@0.8.3/src/Option.mo +0 -154
- package/.mops/base@0.8.3/src/Order.mo +0 -46
- package/.mops/base@0.8.3/src/Prelude.mo +0 -33
- package/.mops/base@0.8.3/src/Principal.mo +0 -249
- package/.mops/base@0.8.3/src/RBTree.mo +0 -681
- package/.mops/base@0.8.3/src/Random.mo +0 -270
- package/.mops/base@0.8.3/src/Result.mo +0 -209
- package/.mops/base@0.8.3/src/Stack.mo +0 -93
- package/.mops/base@0.8.3/src/Text.mo +0 -761
- package/.mops/base@0.8.3/src/Time.mo +0 -36
- package/.mops/base@0.8.3/src/Timer.mo +0 -62
- package/.mops/base@0.8.3/src/Trie.mo +0 -1603
- package/.mops/base@0.8.3/src/TrieMap.mo +0 -392
- package/.mops/base@0.8.3/src/TrieSet.mo +0 -148
- package/network.txt +0 -1
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
/// 16-bit signed integers with checked arithmetic
|
|
2
|
-
///
|
|
3
|
-
/// Most operations are available as built-in operators (e.g. `1 + 1`).
|
|
4
|
-
import Int "Int";
|
|
5
|
-
import Prim "mo:⛔";
|
|
6
|
-
|
|
7
|
-
module {
|
|
8
|
-
|
|
9
|
-
/// 16-bit signed integers
|
|
10
|
-
public type Int16 = Prim.Types.Int16;
|
|
11
|
-
|
|
12
|
-
/// Conversion.
|
|
13
|
-
public let toInt : Int16 -> Int = Prim.int16ToInt;
|
|
14
|
-
|
|
15
|
-
/// Conversion. Traps on overflow/underflow.
|
|
16
|
-
public let fromInt : Int -> Int16 = Prim.intToInt16;
|
|
17
|
-
|
|
18
|
-
/// Conversion. Wraps on overflow/underflow.
|
|
19
|
-
public let fromIntWrap : Int -> Int16 = Prim.intToInt16Wrap;
|
|
20
|
-
|
|
21
|
-
/// Conversion. Wraps on overflow/underflow.
|
|
22
|
-
public let fromNat16 : Nat16 -> Int16 = Prim.nat16ToInt16;
|
|
23
|
-
|
|
24
|
-
/// Conversion. Wraps on overflow/underflow.
|
|
25
|
-
public let toNat16 : Int16 -> Nat16 = Prim.int16ToNat16;
|
|
26
|
-
|
|
27
|
-
/// Returns the Text representation of `x`.
|
|
28
|
-
public func toText(x : Int16) : Text {
|
|
29
|
-
Int.toText(toInt(x))
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
/// Returns the absolute value of `x`. Traps when `x = -2^15`.
|
|
33
|
-
public func abs(x : Int16) : Int16 {
|
|
34
|
-
fromInt(Int.abs(toInt(x)))
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
/// Returns the minimum of `x` and `y`.
|
|
38
|
-
public func min(x : Int16, y : Int16) : Int16 {
|
|
39
|
-
if (x < y) { x } else { y }
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
/// Returns the maximum of `x` and `y`.
|
|
43
|
-
public func max( x : Int16, y : Int16) : Int16 {
|
|
44
|
-
if (x < y) { y } else { x }
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
/// Returns `x == y`.
|
|
48
|
-
public func equal(x : Int16, y : Int16) : Bool { x == y };
|
|
49
|
-
|
|
50
|
-
/// Returns `x != y`.
|
|
51
|
-
public func notEqual(x : Int16, y : Int16) : Bool { x != y };
|
|
52
|
-
|
|
53
|
-
/// Returns `x < y`.
|
|
54
|
-
public func less(x : Int16, y : Int16) : Bool { x < y };
|
|
55
|
-
|
|
56
|
-
/// Returns `x <= y`.
|
|
57
|
-
public func lessOrEqual(x : Int16, y : Int16) : Bool { x <= y };
|
|
58
|
-
|
|
59
|
-
/// Returns `x > y`.
|
|
60
|
-
public func greater(x : Int16, y : Int16) : Bool { x > y };
|
|
61
|
-
|
|
62
|
-
/// Returns `x >= y`.
|
|
63
|
-
public func greaterOrEqual(x : Int16, y : Int16) : Bool { x >= y };
|
|
64
|
-
|
|
65
|
-
/// Returns the order of `x` and `y`.
|
|
66
|
-
public func compare(x : Int16, y : Int16) : { #less; #equal; #greater } {
|
|
67
|
-
if (x < y) { #less }
|
|
68
|
-
else if (x == y) { #equal }
|
|
69
|
-
else { #greater }
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
/// Returns the negation of `x`, `-x`. Traps on overflow.
|
|
73
|
-
public func neg(x : Int16) : Int16 { -x; };
|
|
74
|
-
|
|
75
|
-
/// Returns the sum of `x` and `y`, `x + y`. Traps on overflow.
|
|
76
|
-
public func add(x : Int16, y : Int16) : Int16 { x + y };
|
|
77
|
-
|
|
78
|
-
/// Returns the difference of `x` and `y`, `x - y`. Traps on underflow.
|
|
79
|
-
public func sub(x : Int16, y : Int16) : Int16 { x - y };
|
|
80
|
-
|
|
81
|
-
/// Returns the product of `x` and `y`, `x * y`. Traps on overflow.
|
|
82
|
-
public func mul(x : Int16, y : Int16) : Int16 { x * y };
|
|
83
|
-
|
|
84
|
-
/// Returns the division of `x by y`, `x / y`.
|
|
85
|
-
/// Traps when `y` is zero.
|
|
86
|
-
public func div(x : Int16, y : Int16) : Int16 { x / y };
|
|
87
|
-
|
|
88
|
-
/// Returns the remainder of `x` divided by `y`, `x % y`.
|
|
89
|
-
/// Traps when `y` is zero.
|
|
90
|
-
public func rem(x : Int16, y : Int16) : Int16 { x % y };
|
|
91
|
-
|
|
92
|
-
/// Returns `x` to the power of `y`, `x ** y`. Traps on overflow.
|
|
93
|
-
public func pow(x : Int16, y : Int16) : Int16 { x ** y };
|
|
94
|
-
|
|
95
|
-
/// Returns the bitwise negation of `x`, `^x`.
|
|
96
|
-
public func bitnot(x : Int16, y : Int16) : Int16 { ^x };
|
|
97
|
-
|
|
98
|
-
/// Returns the bitwise and of `x` and `y`, `x & y`.
|
|
99
|
-
public func bitand(x : Int16, y : Int16) : Int16 { x & y };
|
|
100
|
-
|
|
101
|
-
/// Returns the bitwise or of `x` and `y`, `x \| y`.
|
|
102
|
-
public func bitor(x : Int16, y : Int16) : Int16 { x | y };
|
|
103
|
-
|
|
104
|
-
/// Returns the bitwise exclusive or of `x` and `y`, `x ^ y`.
|
|
105
|
-
public func bitxor(x : Int16, y : Int16) : Int16 { x ^ y };
|
|
106
|
-
|
|
107
|
-
/// Returns the bitwise shift left of `x` by `y`, `x << y`.
|
|
108
|
-
public func bitshiftLeft(x : Int16, y : Int16) : Int16 { x << y };
|
|
109
|
-
|
|
110
|
-
/// Returns the bitwise shift right of `x` by `y`, `x >> y`.
|
|
111
|
-
public func bitshiftRight(x : Int16, y : Int16) : Int16 { x >> y };
|
|
112
|
-
|
|
113
|
-
/// Returns the bitwise rotate left of `x` by `y`, `x <<> y`.
|
|
114
|
-
public func bitrotLeft(x : Int16, y : Int16) : Int16 { x <<> y };
|
|
115
|
-
|
|
116
|
-
/// Returns the bitwise rotate right of `x` by `y`, `x <>> y`.
|
|
117
|
-
public func bitrotRight(x : Int16, y : Int16) : Int16 { x <>> y };
|
|
118
|
-
|
|
119
|
-
/// Returns the value of bit `p mod 16` in `x`, `(x & 2^(p mod 16)) == 2^(p mod 16)`.
|
|
120
|
-
public func bittest(x : Int16, p : Nat) : Bool {
|
|
121
|
-
Prim.btstInt16(x, Prim.intToInt16(p));
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
/// Returns the value of setting bit `p mod 16` in `x` to `1`.
|
|
125
|
-
public func bitset(x : Int16, p : Nat) : Int16 {
|
|
126
|
-
x | (1 << Prim.intToInt16(p));
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
/// Returns the value of clearing bit `p mod 16` in `x` to `0`.
|
|
130
|
-
public func bitclear(x : Int16, p : Nat) : Int16 {
|
|
131
|
-
x & ^(1 << Prim.intToInt16(p));
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
/// Returns the value of flipping bit `p mod 16` in `x`.
|
|
135
|
-
public func bitflip(x : Int16, p : Nat) : Int16 {
|
|
136
|
-
x ^ (1 << Prim.intToInt16(p));
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
/// Returns the count of non-zero bits in `x`.
|
|
140
|
-
public let bitcountNonZero : (x : Int16) -> Int16 = Prim.popcntInt16;
|
|
141
|
-
|
|
142
|
-
/// Returns the count of leading zero bits in `x`.
|
|
143
|
-
public let bitcountLeadingZero : (x : Int16) -> Int16 = Prim.clzInt16;
|
|
144
|
-
|
|
145
|
-
/// Returns the count of trailing zero bits in `x`.
|
|
146
|
-
public let bitcountTrailingZero : (x : Int16) -> Int16 = Prim.ctzInt16;
|
|
147
|
-
|
|
148
|
-
/// Returns the sum of `x` and `y`, `x +% y`. Wraps on overflow.
|
|
149
|
-
public func addWrap(x : Int16, y : Int16) : Int16 { x +% y };
|
|
150
|
-
|
|
151
|
-
/// Returns the difference of `x` and `y`, `x -% y`. Wraps on underflow.
|
|
152
|
-
public func subWrap(x : Int16, y : Int16) : Int16 { x -% y };
|
|
153
|
-
|
|
154
|
-
/// Returns the product of `x` and `y`, `x *% y`. Wraps on overflow.
|
|
155
|
-
public func mulWrap(x : Int16, y : Int16) : Int16 { x *% y };
|
|
156
|
-
|
|
157
|
-
/// Returns `x` to the power of `y`, `x **% y`. Wraps on overflow. Traps if `y < 0`.
|
|
158
|
-
public func powWrap(x : Int16, y : Int16) : Int16 { x **% y };
|
|
159
|
-
}
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
/// 32-bit signed integers with checked arithmetic
|
|
2
|
-
///
|
|
3
|
-
/// Most operations are available as built-in operators (e.g. `1 + 1`).
|
|
4
|
-
import Int "Int";
|
|
5
|
-
import Prim "mo:⛔";
|
|
6
|
-
|
|
7
|
-
module {
|
|
8
|
-
|
|
9
|
-
/// 32-bit signed integers.
|
|
10
|
-
public type Int32 = Prim.Types.Int32;
|
|
11
|
-
|
|
12
|
-
/// Conversion.
|
|
13
|
-
public let toInt : Int32 -> Int = Prim.int32ToInt;
|
|
14
|
-
|
|
15
|
-
/// Conversion. Traps on overflow/underflow.
|
|
16
|
-
public let fromInt : Int -> Int32 = Prim.intToInt32;
|
|
17
|
-
|
|
18
|
-
/// Conversion. Wraps on overflow/underflow.
|
|
19
|
-
public let fromIntWrap : Int -> Int32 = Prim.intToInt32Wrap;
|
|
20
|
-
|
|
21
|
-
/// Conversion. Wraps on overflow/underflow.
|
|
22
|
-
public let fromNat32 : Nat32 -> Int32 = Prim.nat32ToInt32;
|
|
23
|
-
|
|
24
|
-
/// Conversion. Wraps on overflow/underflow.
|
|
25
|
-
public let toNat32 : Int32 -> Nat32 = Prim.int32ToNat32;
|
|
26
|
-
|
|
27
|
-
/// Returns the Text representation of `x`.
|
|
28
|
-
public func toText(x : Int32) : Text {
|
|
29
|
-
Int.toText(toInt(x))
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
/// Returns the absolute value of `x`. Traps when `x = -2^31`.
|
|
33
|
-
public func abs(x : Int32) : Int32 {
|
|
34
|
-
fromInt(Int.abs(toInt(x)))
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
/// Returns the minimum of `x` and `y`.
|
|
38
|
-
public func min(x : Int32, y : Int32) : Int32 {
|
|
39
|
-
if (x < y) { x } else { y }
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
/// Returns the maximum of `x` and `y`.
|
|
43
|
-
public func max( x : Int32, y : Int32) : Int32 {
|
|
44
|
-
if (x < y) { y } else { x }
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
/// Returns `x == y`.
|
|
48
|
-
public func equal(x : Int32, y : Int32) : Bool { x == y };
|
|
49
|
-
|
|
50
|
-
/// Returns `x != y`.
|
|
51
|
-
public func notEqual(x : Int32, y : Int32) : Bool { x != y };
|
|
52
|
-
|
|
53
|
-
/// Returns `x < y`.
|
|
54
|
-
public func less(x : Int32, y : Int32) : Bool { x < y };
|
|
55
|
-
|
|
56
|
-
/// Returns `x <= y`.
|
|
57
|
-
public func lessOrEqual(x : Int32, y : Int32) : Bool { x <= y };
|
|
58
|
-
|
|
59
|
-
/// Returns `x > y`.
|
|
60
|
-
public func greater(x : Int32, y : Int32) : Bool { x > y };
|
|
61
|
-
|
|
62
|
-
/// Returns `x >= y`.
|
|
63
|
-
public func greaterOrEqual(x : Int32, y : Int32) : Bool { x >= y };
|
|
64
|
-
|
|
65
|
-
/// Returns the order of `x` and `y`.
|
|
66
|
-
public func compare(x : Int32, y : Int32) : { #less; #equal; #greater } {
|
|
67
|
-
if (x < y) { #less }
|
|
68
|
-
else if (x == y) { #equal }
|
|
69
|
-
else { #greater }
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
/// Returns the negation of `x`, `-x`. Traps on overflow.
|
|
73
|
-
public func neg(x : Int32) : Int32 { -x; };
|
|
74
|
-
|
|
75
|
-
/// Returns the sum of `x` and `y`, `x + y`. Traps on overflow.
|
|
76
|
-
public func add(x : Int32, y : Int32) : Int32 { x + y };
|
|
77
|
-
|
|
78
|
-
/// Returns the difference of `x` and `y`, `x - y`. Traps on underflow.
|
|
79
|
-
public func sub(x : Int32, y : Int32) : Int32 { x - y };
|
|
80
|
-
|
|
81
|
-
/// Returns the product of `x` and `y`, `x * y`. Traps on overflow.
|
|
82
|
-
public func mul(x : Int32, y : Int32) : Int32 { x * y };
|
|
83
|
-
|
|
84
|
-
/// Returns the division of `x by y`, `x / y`.
|
|
85
|
-
/// Traps when `y` is zero.
|
|
86
|
-
public func div(x : Int32, y : Int32) : Int32 { x / y };
|
|
87
|
-
|
|
88
|
-
/// Returns the remainder of `x` divided by `y`, `x % y`.
|
|
89
|
-
/// Traps when `y` is zero.
|
|
90
|
-
public func rem(x : Int32, y : Int32) : Int32 { x % y };
|
|
91
|
-
|
|
92
|
-
/// Returns `x` to the power of `y`, `x ** y`. Traps on overflow.
|
|
93
|
-
public func pow(x : Int32, y : Int32) : Int32 { x ** y };
|
|
94
|
-
|
|
95
|
-
/// Returns the bitwise negation of `x`, `^x`.
|
|
96
|
-
public func bitnot(x : Int32, y : Int32) : Int32 { ^x };
|
|
97
|
-
|
|
98
|
-
/// Returns the bitwise and of `x` and `y`, `x & y`.
|
|
99
|
-
public func bitand(x : Int32, y : Int32) : Int32 { x & y };
|
|
100
|
-
|
|
101
|
-
/// Returns the bitwise or of `x` and `y`, `x \| y`.
|
|
102
|
-
public func bitor(x : Int32, y : Int32) : Int32 { x | y };
|
|
103
|
-
|
|
104
|
-
/// Returns the bitwise exclusive or of `x` and `y`, `x ^ y`.
|
|
105
|
-
public func bitxor(x : Int32, y : Int32) : Int32 { x ^ y };
|
|
106
|
-
|
|
107
|
-
/// Returns the bitwise shift left of `x` by `y`, `x << y`.
|
|
108
|
-
public func bitshiftLeft(x : Int32, y : Int32) : Int32 { x << y };
|
|
109
|
-
|
|
110
|
-
/// Returns the bitwise shift right of `x` by `y`, `x >> y`.
|
|
111
|
-
public func bitshiftRight(x : Int32, y : Int32) : Int32 { x >> y };
|
|
112
|
-
|
|
113
|
-
/// Returns the bitwise rotate left of `x` by `y`, `x <<> y`.
|
|
114
|
-
public func bitrotLeft(x : Int32, y : Int32) : Int32 { x <<> y };
|
|
115
|
-
|
|
116
|
-
/// Returns the bitwise rotate right of `x` by `y`, `x <>> y`.
|
|
117
|
-
public func bitrotRight(x : Int32, y : Int32) : Int32 { x <>> y };
|
|
118
|
-
|
|
119
|
-
/// Returns the value of bit `p mod 16` in `x`, `(x & 2^(p mod 16)) == 2^(p mod 16)`.
|
|
120
|
-
public func bittest(x : Int32, p : Nat) : Bool {
|
|
121
|
-
Prim.btstInt32(x, Prim.intToInt32(p));
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
/// Returns the value of setting bit `p mod 16` in `x` to `1`.
|
|
125
|
-
public func bitset(x : Int32, p : Nat) : Int32 {
|
|
126
|
-
x | (1 << Prim.intToInt32(p));
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
/// Returns the value of clearing bit `p mod 16` in `x` to `0`.
|
|
130
|
-
public func bitclear(x : Int32, p : Nat) : Int32 {
|
|
131
|
-
x & ^(1 << Prim.intToInt32(p));
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
/// Returns the value of flipping bit `p mod 16` in `x`.
|
|
135
|
-
public func bitflip(x : Int32, p : Nat) : Int32 {
|
|
136
|
-
x ^ (1 << Prim.intToInt32(p));
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
/// Returns the count of non-zero bits in `x`.
|
|
140
|
-
public let bitcountNonZero : (x : Int32) -> Int32 = Prim.popcntInt32;
|
|
141
|
-
|
|
142
|
-
/// Returns the count of leading zero bits in `x`.
|
|
143
|
-
public let bitcountLeadingZero : (x : Int32) -> Int32 = Prim.clzInt32;
|
|
144
|
-
|
|
145
|
-
/// Returns the count of trailing zero bits in `x`.
|
|
146
|
-
public let bitcountTrailingZero : (x : Int32) -> Int32 = Prim.ctzInt32;
|
|
147
|
-
|
|
148
|
-
/// Returns the sum of `x` and `y`, `x +% y`. Wraps on overflow.
|
|
149
|
-
public func addWrap(x : Int32, y : Int32) : Int32 { x +% y };
|
|
150
|
-
|
|
151
|
-
/// Returns the difference of `x` and `y`, `x -% y`. Wraps on underflow.
|
|
152
|
-
public func subWrap(x : Int32, y : Int32) : Int32 { x -% y };
|
|
153
|
-
|
|
154
|
-
/// Returns the product of `x` and `y`, `x *% y`. Wraps on overflow.
|
|
155
|
-
public func mulWrap(x : Int32, y : Int32) : Int32 { x *% y };
|
|
156
|
-
|
|
157
|
-
/// Returns `x` to the power of `y`, `x **% y`. Wraps on overflow. Traps if `y < 0`.
|
|
158
|
-
public func powWrap(x : Int32, y : Int32) : Int32 { x **% y };
|
|
159
|
-
|
|
160
|
-
}
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
/// 64-bit signed integers with checked arithmetic
|
|
2
|
-
///
|
|
3
|
-
/// Most operations are available as built-in operators (e.g. `1 + 1`).
|
|
4
|
-
import Int "Int";
|
|
5
|
-
import Prim "mo:⛔";
|
|
6
|
-
|
|
7
|
-
module {
|
|
8
|
-
|
|
9
|
-
/// 64-bit signed integers.
|
|
10
|
-
public type Int64 = Prim.Types.Int64;
|
|
11
|
-
|
|
12
|
-
/// Conversion.
|
|
13
|
-
public let toInt : Int64 -> Int = Prim.int64ToInt;
|
|
14
|
-
|
|
15
|
-
/// Conversion. Traps on overflow/underflow.
|
|
16
|
-
public let fromInt : Int -> Int64 = Prim.intToInt64;
|
|
17
|
-
|
|
18
|
-
/// Conversion. Wraps on overflow/underflow.
|
|
19
|
-
public let fromIntWrap : Int -> Int64 = Prim.intToInt64Wrap;
|
|
20
|
-
|
|
21
|
-
/// Conversion. Wraps on overflow/underflow.
|
|
22
|
-
public let fromNat64 : Nat64 -> Int64 = Prim.nat64ToInt64;
|
|
23
|
-
|
|
24
|
-
/// Conversion. Wraps on overflow/underflow.
|
|
25
|
-
public let toNat64 : Int64 -> Nat64 = Prim.int64ToNat64;
|
|
26
|
-
|
|
27
|
-
/// Returns the Text representation of `x`.
|
|
28
|
-
public func toText(x : Int64) : Text {
|
|
29
|
-
Int.toText(toInt(x))
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
/// Returns the absolute value of `x`. Traps when `x = -2^63`.
|
|
33
|
-
public func abs(x : Int64) : Int64 {
|
|
34
|
-
fromInt(Int.abs(toInt(x)))
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
/// Returns the minimum of `x` and `y`.
|
|
38
|
-
public func min(x : Int64, y : Int64) : Int64 {
|
|
39
|
-
if (x < y) { x } else { y }
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
/// Returns the maximum of `x` and `y`.
|
|
43
|
-
public func max( x : Int64, y : Int64) : Int64 {
|
|
44
|
-
if (x < y) { y } else { x }
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
/// Returns `x == y`.
|
|
48
|
-
public func equal(x : Int64, y : Int64) : Bool { x == y };
|
|
49
|
-
|
|
50
|
-
/// Returns `x != y`.
|
|
51
|
-
public func notEqual(x : Int64, y : Int64) : Bool { x != y };
|
|
52
|
-
|
|
53
|
-
/// Returns `x < y`.
|
|
54
|
-
public func less(x : Int64, y : Int64) : Bool { x < y };
|
|
55
|
-
|
|
56
|
-
/// Returns `x <= y`.
|
|
57
|
-
public func lessOrEqual(x : Int64, y : Int64) : Bool { x <= y };
|
|
58
|
-
|
|
59
|
-
/// Returns `x > y`.
|
|
60
|
-
public func greater(x : Int64, y : Int64) : Bool { x > y };
|
|
61
|
-
|
|
62
|
-
/// Returns `x >= y`.
|
|
63
|
-
public func greaterOrEqual(x : Int64, y : Int64) : Bool { x >= y };
|
|
64
|
-
|
|
65
|
-
/// Returns the order of `x` and `y`.
|
|
66
|
-
public func compare(x : Int64, y : Int64) : { #less; #equal; #greater } {
|
|
67
|
-
if (x < y) { #less }
|
|
68
|
-
else if (x == y) { #equal }
|
|
69
|
-
else { #greater }
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
/// Returns the negation of `x`, `-x`. Traps on overflow.
|
|
73
|
-
public func neg(x : Int64) : Int64 { -x; };
|
|
74
|
-
|
|
75
|
-
/// Returns the sum of `x` and `y`, `x + y`. Traps on overflow.
|
|
76
|
-
public func add(x : Int64, y : Int64) : Int64 { x + y };
|
|
77
|
-
|
|
78
|
-
/// Returns the difference of `x` and `y`, `x - y`. Traps on underflow.
|
|
79
|
-
public func sub(x : Int64, y : Int64) : Int64 { x - y };
|
|
80
|
-
|
|
81
|
-
/// Returns the product of `x` and `y`, `x * y`. Traps on overflow.
|
|
82
|
-
public func mul(x : Int64, y : Int64) : Int64 { x * y };
|
|
83
|
-
|
|
84
|
-
/// Returns the division of `x by y`, `x / y`.
|
|
85
|
-
/// Traps when `y` is zero.
|
|
86
|
-
public func div(x : Int64, y : Int64) : Int64 { x / y };
|
|
87
|
-
|
|
88
|
-
/// Returns the remainder of `x` divided by `y`, `x % y`.
|
|
89
|
-
/// Traps when `y` is zero.
|
|
90
|
-
public func rem(x : Int64, y : Int64) : Int64 { x % y };
|
|
91
|
-
|
|
92
|
-
/// Returns `x` to the power of `y`, `x ** y`. Traps on overflow.
|
|
93
|
-
public func pow(x : Int64, y : Int64) : Int64 { x ** y };
|
|
94
|
-
|
|
95
|
-
/// Returns the bitwise negation of `x`, `^x`.
|
|
96
|
-
public func bitnot(x : Int64, y : Int64) : Int64 { ^x };
|
|
97
|
-
|
|
98
|
-
/// Returns the bitwise and of `x` and `y`, `x & y`.
|
|
99
|
-
public func bitand(x : Int64, y : Int64) : Int64 { x & y };
|
|
100
|
-
|
|
101
|
-
/// Returns the bitwise or of `x` and `y`, `x \| y`.
|
|
102
|
-
public func bitor(x : Int64, y : Int64) : Int64 { x | y };
|
|
103
|
-
|
|
104
|
-
/// Returns the bitwise exclusive or of `x` and `y`, `x ^ y`.
|
|
105
|
-
public func bitxor(x : Int64, y : Int64) : Int64 { x ^ y };
|
|
106
|
-
|
|
107
|
-
/// Returns the bitwise shift left of `x` by `y`, `x << y`.
|
|
108
|
-
public func bitshiftLeft(x : Int64, y : Int64) : Int64 { x << y };
|
|
109
|
-
|
|
110
|
-
/// Returns the bitwise shift right of `x` by `y`, `x >> y`.
|
|
111
|
-
public func bitshiftRight(x : Int64, y : Int64) : Int64 { x >> y };
|
|
112
|
-
|
|
113
|
-
/// Returns the bitwise rotate left of `x` by `y`, `x <<> y`.
|
|
114
|
-
public func bitrotLeft(x : Int64, y : Int64) : Int64 { x <<> y };
|
|
115
|
-
|
|
116
|
-
/// Returns the bitwise rotate right of `x` by `y`, `x <>> y`.
|
|
117
|
-
public func bitrotRight(x : Int64, y : Int64) : Int64 { x <>> y };
|
|
118
|
-
|
|
119
|
-
/// Returns the value of bit `p mod 64` in `x`, `(x & 2^(p mod 64)) == 2^(p mod 64)`.
|
|
120
|
-
public func bittest(x : Int64, p : Nat) : Bool {
|
|
121
|
-
Prim.btstInt64(x, Prim.intToInt64(p));
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
/// Returns the value of setting bit `p mod 64` in `x` to `1`.
|
|
125
|
-
public func bitset(x : Int64, p : Nat) : Int64 {
|
|
126
|
-
x | (1 << Prim.intToInt64(p));
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
/// Returns the value of clearing bit `p mod 64` in `x` to `0`.
|
|
130
|
-
public func bitclear(x : Int64, p : Nat) : Int64 {
|
|
131
|
-
x & ^(1 << Prim.intToInt64(p));
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
/// Returns the value of flipping bit `p mod 64` in `x`.
|
|
135
|
-
public func bitflip(x : Int64, p : Nat) : Int64 {
|
|
136
|
-
x ^ (1 << Prim.intToInt64(p));
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
/// Returns the count of non-zero bits in `x`.
|
|
140
|
-
public let bitcountNonZero : (x : Int64) -> Int64 = Prim.popcntInt64;
|
|
141
|
-
|
|
142
|
-
/// Returns the count of leading zero bits in `x`.
|
|
143
|
-
public let bitcountLeadingZero : (x : Int64) -> Int64 = Prim.clzInt64;
|
|
144
|
-
|
|
145
|
-
/// Returns the count of trailing zero bits in `x`.
|
|
146
|
-
public let bitcountTrailingZero : (x : Int64) -> Int64 = Prim.ctzInt64;
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
/// Returns the sum of `x` and `y`, `x +% y`. Wraps on overflow.
|
|
150
|
-
public func addWrap(x : Int64, y : Int64) : Int64 { x +% y };
|
|
151
|
-
|
|
152
|
-
/// Returns the difference of `x` and `y`, `x -% y`. Wraps on underflow.
|
|
153
|
-
public func subWrap(x : Int64, y : Int64) : Int64 { x -% y };
|
|
154
|
-
|
|
155
|
-
/// Returns the product of `x` and `y`, `x *% y`. Wraps on overflow.
|
|
156
|
-
public func mulWrap(x : Int64, y : Int64) : Int64 { x *% y };
|
|
157
|
-
|
|
158
|
-
/// Returns `x` to the power of `y`, `x **% y`. Wraps on overflow. Traps if `y < 0`.
|
|
159
|
-
public func powWrap(x : Int64, y : Int64) : Int64 { x **% y };
|
|
160
|
-
|
|
161
|
-
}
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
/// 8-bit signed integers with checked arithmetic
|
|
2
|
-
///
|
|
3
|
-
/// Most operations are available as built-in operators (e.g. `1 + 1`).
|
|
4
|
-
import Int "Int";
|
|
5
|
-
import Prim "mo:⛔";
|
|
6
|
-
|
|
7
|
-
module {
|
|
8
|
-
|
|
9
|
-
/// 8-bit signed integers.
|
|
10
|
-
public type Int8 = Prim.Types.Int8;
|
|
11
|
-
|
|
12
|
-
/// Conversion.
|
|
13
|
-
public let toInt : Int8 -> Int = Prim.int8ToInt;
|
|
14
|
-
|
|
15
|
-
/// Conversion. Traps on overflow/underflow.
|
|
16
|
-
public let fromInt : Int -> Int8 = Prim.intToInt8;
|
|
17
|
-
|
|
18
|
-
/// Conversion. Wraps on overflow/underflow.
|
|
19
|
-
public let fromIntWrap : Int -> Int8 = Prim.intToInt8Wrap;
|
|
20
|
-
|
|
21
|
-
/// Conversion. Wraps on overflow/underflow.
|
|
22
|
-
public let fromNat8 : Nat8 -> Int8 = Prim.nat8ToInt8;
|
|
23
|
-
|
|
24
|
-
/// Conversion. Wraps on overflow/underflow.
|
|
25
|
-
public let toNat8 : Int8 -> Nat8 = Prim.int8ToNat8;
|
|
26
|
-
|
|
27
|
-
/// Returns the Text representation of `x`.
|
|
28
|
-
public func toText(x : Int8) : Text {
|
|
29
|
-
Int.toText(toInt(x))
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
/// Returns the absolute value of `x`. Traps when `x = -2^7`.
|
|
33
|
-
public func abs(x : Int8) : Int8 {
|
|
34
|
-
fromInt(Int.abs(toInt(x)))
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
/// Returns the minimum of `x` and `y`.
|
|
38
|
-
public func min(x : Int8, y : Int8) : Int8 {
|
|
39
|
-
if (x < y) { x } else { y }
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
/// Returns the maximum of `x` and `y`.
|
|
43
|
-
public func max( x : Int8, y : Int8) : Int8 {
|
|
44
|
-
if (x < y) { y } else { x }
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
/// Returns `x == y`.
|
|
48
|
-
public func equal(x : Int8, y : Int8) : Bool { x == y };
|
|
49
|
-
|
|
50
|
-
/// Returns `x != y`.
|
|
51
|
-
public func notEqual(x : Int8, y : Int8) : Bool { x != y };
|
|
52
|
-
|
|
53
|
-
/// Returns `x < y`.
|
|
54
|
-
public func less(x : Int8, y : Int8) : Bool { x < y };
|
|
55
|
-
|
|
56
|
-
/// Returns `x <= y`.
|
|
57
|
-
public func lessOrEqual(x : Int8, y : Int8) : Bool { x <= y };
|
|
58
|
-
|
|
59
|
-
/// Returns `x > y`.
|
|
60
|
-
public func greater(x : Int8, y : Int8) : Bool { x > y };
|
|
61
|
-
|
|
62
|
-
/// Returns `x >= y`.
|
|
63
|
-
public func greaterOrEqual(x : Int8, y : Int8) : Bool { x >= y };
|
|
64
|
-
|
|
65
|
-
/// Returns the order of `x` and `y`.
|
|
66
|
-
public func compare(x : Int8, y : Int8) : { #less; #equal; #greater } {
|
|
67
|
-
if (x < y) { #less }
|
|
68
|
-
else if (x == y) { #equal }
|
|
69
|
-
else { #greater }
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
/// Returns the negation of `x`, `-x`. Traps on overflow.
|
|
73
|
-
public func neg(x : Int8) : Int8 { -x; };
|
|
74
|
-
|
|
75
|
-
/// Returns the sum of `x` and `y`, `x + y`. Traps on overflow.
|
|
76
|
-
public func add(x : Int8, y : Int8) : Int8 { x + y };
|
|
77
|
-
|
|
78
|
-
/// Returns the difference of `x` and `y`, `x - y`. Traps on underflow.
|
|
79
|
-
public func sub(x : Int8, y : Int8) : Int8 { x - y };
|
|
80
|
-
|
|
81
|
-
/// Returns the product of `x` and `y`, `x * y`. Traps on overflow.
|
|
82
|
-
public func mul(x : Int8, y : Int8) : Int8 { x * y };
|
|
83
|
-
|
|
84
|
-
/// Returns the division of `x by y`, `x / y`.
|
|
85
|
-
/// Traps when `y` is zero.
|
|
86
|
-
public func div(x : Int8, y : Int8) : Int8 { x / y };
|
|
87
|
-
|
|
88
|
-
/// Returns the remainder of `x` divided by `y`, `x % y`.
|
|
89
|
-
/// Traps when `y` is zero.
|
|
90
|
-
public func rem(x : Int8, y : Int8) : Int8 { x % y };
|
|
91
|
-
|
|
92
|
-
/// Returns `x` to the power of `y`, `x ** y`. Traps on overflow.
|
|
93
|
-
public func pow(x : Int8, y : Int8) : Int8 { x ** y };
|
|
94
|
-
|
|
95
|
-
/// Returns the bitwise negation of `x`, `^x`.
|
|
96
|
-
public func bitnot(x : Int8, y : Int8) : Int8 { ^x };
|
|
97
|
-
|
|
98
|
-
/// Returns the bitwise and of `x` and `y`, `x & y`.
|
|
99
|
-
public func bitand(x : Int8, y : Int8) : Int8 { x & y };
|
|
100
|
-
|
|
101
|
-
/// Returns the bitwise or of `x` and `y`, `x \| y`.
|
|
102
|
-
public func bitor(x : Int8, y : Int8) : Int8 { x | y };
|
|
103
|
-
|
|
104
|
-
/// Returns the bitwise exclusive or of `x` and `y`, `x ^ y`.
|
|
105
|
-
public func bitxor(x : Int8, y : Int8) : Int8 { x ^ y };
|
|
106
|
-
|
|
107
|
-
/// Returns the bitwise shift left of `x` by `y`, `x << y`.
|
|
108
|
-
public func bitshiftLeft(x : Int8, y : Int8) : Int8 { x << y };
|
|
109
|
-
|
|
110
|
-
/// Returns the bitwise shift right of `x` by `y`, `x >> y`.
|
|
111
|
-
public func bitshiftRight(x : Int8, y : Int8) : Int8 { x >> y };
|
|
112
|
-
|
|
113
|
-
/// Returns the bitwise rotate left of `x` by `y`, `x <<> y`.
|
|
114
|
-
public func bitrotLeft(x : Int8, y : Int8) : Int8 { x <<> y };
|
|
115
|
-
|
|
116
|
-
/// Returns the bitwise rotate right of `x` by `y`, `x <>> y`.
|
|
117
|
-
public func bitrotRight(x : Int8, y : Int8) : Int8 { x <>> y };
|
|
118
|
-
|
|
119
|
-
/// Returns the value of bit `p mod 8` in `x`, `(x & 2^(p mod 8)) == 2^(p mod 8)`.
|
|
120
|
-
public func bittest(x : Int8, p : Nat) : Bool {
|
|
121
|
-
Prim.btstInt8(x, Prim.intToInt8(p));
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
/// Returns the value of setting bit `p mod 8` in `x` to `1`.
|
|
125
|
-
public func bitset(x : Int8, p : Nat) : Int8 {
|
|
126
|
-
x | (1 << Prim.intToInt8(p));
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
/// Returns the value of clearing bit `p mod 8` in `x` to `0`.
|
|
130
|
-
public func bitclear(x : Int8, p : Nat) : Int8 {
|
|
131
|
-
x & ^(1 << Prim.intToInt8(p));
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
/// Returns the value of flipping bit `p mod 8` in `x`.
|
|
135
|
-
public func bitflip(x : Int8, p : Nat) : Int8 {
|
|
136
|
-
x ^ (1 << Prim.intToInt8(p));
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
/// Returns the count of non-zero bits in `x`.
|
|
140
|
-
public let bitcountNonZero : (x : Int8) -> Int8 = Prim.popcntInt8;
|
|
141
|
-
|
|
142
|
-
/// Returns the count of leading zero bits in `x`.
|
|
143
|
-
public let bitcountLeadingZero : (x : Int8) -> Int8 = Prim.clzInt8;
|
|
144
|
-
|
|
145
|
-
/// Returns the count of trailing zero bits in `x`.
|
|
146
|
-
public let bitcountTrailingZero : (x : Int8) -> Int8 = Prim.ctzInt8;
|
|
147
|
-
|
|
148
|
-
/// Returns the sum of `x` and `y`, `x +% y`. Wraps on overflow.
|
|
149
|
-
public func addWrap(x : Int8, y : Int8) : Int8 { x +% y };
|
|
150
|
-
|
|
151
|
-
/// Returns the difference of `x` and `y`, `x -% y`. Wraps on underflow.
|
|
152
|
-
public func subWrap(x : Int8, y : Int8) : Int8 { x -% y };
|
|
153
|
-
|
|
154
|
-
/// Returns the product of `x` and `y`, `x *% y`. Wraps on overflow.
|
|
155
|
-
public func mulWrap(x : Int8, y : Int8) : Int8 { x *% y };
|
|
156
|
-
|
|
157
|
-
/// Returns `x` to the power of `y`, `x **% y`. Wraps on overflow. Traps if `y < 0`.
|
|
158
|
-
public func powWrap(x : Int8, y : Int8) : Int8 { x **% y };
|
|
159
|
-
|
|
160
|
-
}
|