@grain/stdlib 0.5.13 → 0.6.0
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/CHANGELOG.md +193 -0
- package/LICENSE +1 -1
- package/README.md +25 -2
- package/array.gr +1512 -199
- package/array.md +2032 -94
- package/bigint.gr +239 -140
- package/bigint.md +450 -106
- package/buffer.gr +595 -102
- package/buffer.md +903 -145
- package/bytes.gr +401 -110
- package/bytes.md +551 -63
- package/char.gr +228 -49
- package/char.md +373 -7
- package/exception.gr +26 -12
- package/exception.md +29 -5
- package/float32.gr +130 -109
- package/float32.md +185 -57
- package/float64.gr +112 -99
- package/float64.md +185 -57
- package/hash.gr +47 -37
- package/hash.md +21 -3
- package/int16.gr +430 -0
- package/int16.md +618 -0
- package/int32.gr +200 -269
- package/int32.md +254 -289
- package/int64.gr +142 -225
- package/int64.md +254 -289
- package/int8.gr +511 -0
- package/int8.md +786 -0
- package/json.gr +2084 -0
- package/json.md +608 -0
- package/list.gr +120 -68
- package/list.md +125 -80
- package/map.gr +560 -57
- package/map.md +672 -56
- package/marshal.gr +239 -227
- package/marshal.md +36 -4
- package/number.gr +626 -676
- package/number.md +738 -153
- package/option.gr +33 -35
- package/option.md +58 -42
- package/package.json +2 -2
- package/path.gr +148 -187
- package/path.md +47 -96
- package/pervasives.gr +75 -416
- package/pervasives.md +85 -180
- package/priorityqueue.gr +433 -74
- package/priorityqueue.md +422 -54
- package/queue.gr +362 -80
- package/queue.md +433 -38
- package/random.gr +67 -75
- package/random.md +68 -40
- package/range.gr +135 -63
- package/range.md +198 -43
- package/rational.gr +284 -0
- package/rational.md +545 -0
- package/regex.gr +933 -1066
- package/regex.md +59 -60
- package/result.gr +23 -25
- package/result.md +54 -39
- package/runtime/atof/common.gr +78 -82
- package/runtime/atof/common.md +22 -10
- package/runtime/atof/decimal.gr +102 -127
- package/runtime/atof/decimal.md +28 -7
- package/runtime/atof/lemire.gr +56 -71
- package/runtime/atof/lemire.md +9 -1
- package/runtime/atof/parse.gr +83 -110
- package/runtime/atof/parse.md +12 -2
- package/runtime/atof/slow.gr +28 -35
- package/runtime/atof/slow.md +9 -1
- package/runtime/atof/table.gr +19 -18
- package/runtime/atof/table.md +10 -2
- package/runtime/atoi/parse.gr +153 -136
- package/runtime/atoi/parse.md +50 -1
- package/runtime/bigint.gr +410 -517
- package/runtime/bigint.md +71 -57
- package/runtime/compare.gr +176 -85
- package/runtime/compare.md +31 -1
- package/runtime/dataStructures.gr +144 -32
- package/runtime/dataStructures.md +267 -31
- package/runtime/debugPrint.gr +34 -15
- package/runtime/debugPrint.md +37 -5
- package/runtime/equal.gr +53 -52
- package/runtime/equal.md +30 -1
- package/runtime/exception.gr +38 -47
- package/runtime/exception.md +10 -8
- package/runtime/gc.gr +23 -152
- package/runtime/gc.md +13 -17
- package/runtime/malloc.gr +31 -31
- package/runtime/malloc.md +11 -3
- package/runtime/numberUtils.gr +191 -172
- package/runtime/numberUtils.md +17 -9
- package/runtime/numbers.gr +1695 -1021
- package/runtime/numbers.md +1098 -134
- package/runtime/string.gr +540 -242
- package/runtime/string.md +76 -6
- package/runtime/unsafe/constants.gr +30 -13
- package/runtime/unsafe/constants.md +80 -0
- package/runtime/unsafe/conv.gr +55 -28
- package/runtime/unsafe/conv.md +41 -9
- package/runtime/unsafe/memory.gr +10 -30
- package/runtime/unsafe/memory.md +15 -19
- package/runtime/unsafe/tags.gr +37 -21
- package/runtime/unsafe/tags.md +88 -8
- package/runtime/unsafe/wasmf32.gr +30 -36
- package/runtime/unsafe/wasmf32.md +64 -56
- package/runtime/unsafe/wasmf64.gr +30 -36
- package/runtime/unsafe/wasmf64.md +64 -56
- package/runtime/unsafe/wasmi32.gr +49 -66
- package/runtime/unsafe/wasmi32.md +102 -94
- package/runtime/unsafe/wasmi64.gr +52 -79
- package/runtime/unsafe/wasmi64.md +108 -100
- package/runtime/utils/printing.gr +13 -15
- package/runtime/utils/printing.md +11 -3
- package/runtime/wasi.gr +294 -295
- package/runtime/wasi.md +62 -42
- package/set.gr +574 -64
- package/set.md +634 -54
- package/stack.gr +181 -64
- package/stack.md +271 -42
- package/string.gr +453 -533
- package/string.md +241 -151
- package/uint16.gr +369 -0
- package/uint16.md +585 -0
- package/uint32.gr +470 -0
- package/uint32.md +737 -0
- package/uint64.gr +471 -0
- package/uint64.md +737 -0
- package/uint8.gr +369 -0
- package/uint8.md +585 -0
- package/uri.gr +1093 -0
- package/uri.md +477 -0
- package/{sys → wasi}/file.gr +914 -500
- package/{sys → wasi}/file.md +454 -50
- package/wasi/process.gr +292 -0
- package/{sys → wasi}/process.md +164 -6
- package/wasi/random.gr +77 -0
- package/wasi/random.md +80 -0
- package/{sys → wasi}/time.gr +15 -22
- package/{sys → wasi}/time.md +5 -5
- package/immutablearray.gr +0 -929
- package/immutablearray.md +0 -1038
- package/immutablemap.gr +0 -493
- package/immutablemap.md +0 -479
- package/immutablepriorityqueue.gr +0 -360
- package/immutablepriorityqueue.md +0 -291
- package/immutableset.gr +0 -498
- package/immutableset.md +0 -449
- package/runtime/debug.gr +0 -2
- package/runtime/debug.md +0 -6
- package/runtime/unsafe/errors.gr +0 -36
- package/runtime/unsafe/errors.md +0 -204
- package/sys/process.gr +0 -254
- package/sys/random.gr +0 -79
- package/sys/random.md +0 -66
package/rational.md
ADDED
|
@@ -0,0 +1,545 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Rational
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Utilities for working with the Rational type.
|
|
6
|
+
|
|
7
|
+
<details disabled>
|
|
8
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
9
|
+
No other changes yet.
|
|
10
|
+
</details>
|
|
11
|
+
|
|
12
|
+
```grain
|
|
13
|
+
from "rational" include Rational
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
```grain
|
|
17
|
+
1/2r
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
```grain
|
|
21
|
+
3/4r
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Values
|
|
25
|
+
|
|
26
|
+
Functions and constants included in the Rational module.
|
|
27
|
+
|
|
28
|
+
### Rational.**fromNumber**
|
|
29
|
+
|
|
30
|
+
<details disabled>
|
|
31
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
32
|
+
No other changes yet.
|
|
33
|
+
</details>
|
|
34
|
+
|
|
35
|
+
```grain
|
|
36
|
+
fromNumber : (number: Number) => Rational
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Converts a Number to a Rational.
|
|
40
|
+
|
|
41
|
+
Parameters:
|
|
42
|
+
|
|
43
|
+
|param|type|description|
|
|
44
|
+
|-----|----|-----------|
|
|
45
|
+
|`number`|`Number`|The value to convert|
|
|
46
|
+
|
|
47
|
+
Returns:
|
|
48
|
+
|
|
49
|
+
|type|description|
|
|
50
|
+
|----|-----------|
|
|
51
|
+
|`Rational`|The Number represented as a Rational|
|
|
52
|
+
|
|
53
|
+
### Rational.**toNumber**
|
|
54
|
+
|
|
55
|
+
<details disabled>
|
|
56
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
57
|
+
No other changes yet.
|
|
58
|
+
</details>
|
|
59
|
+
|
|
60
|
+
```grain
|
|
61
|
+
toNumber : (rational: Rational) => Number
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Converts a Rational to a Number.
|
|
65
|
+
|
|
66
|
+
Parameters:
|
|
67
|
+
|
|
68
|
+
|param|type|description|
|
|
69
|
+
|-----|----|-----------|
|
|
70
|
+
|`rational`|`Rational`|The value to convert|
|
|
71
|
+
|
|
72
|
+
Returns:
|
|
73
|
+
|
|
74
|
+
|type|description|
|
|
75
|
+
|----|-----------|
|
|
76
|
+
|`Number`|The Rational represented as a Number|
|
|
77
|
+
|
|
78
|
+
### Rational.**numerator**
|
|
79
|
+
|
|
80
|
+
<details disabled>
|
|
81
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
82
|
+
No other changes yet.
|
|
83
|
+
</details>
|
|
84
|
+
|
|
85
|
+
```grain
|
|
86
|
+
numerator : (x: Rational) => Number
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Finds the numerator of the rational number.
|
|
90
|
+
|
|
91
|
+
Parameters:
|
|
92
|
+
|
|
93
|
+
|param|type|description|
|
|
94
|
+
|-----|----|-----------|
|
|
95
|
+
|`x`|`Rational`|The rational number to inspect|
|
|
96
|
+
|
|
97
|
+
Returns:
|
|
98
|
+
|
|
99
|
+
|type|description|
|
|
100
|
+
|----|-----------|
|
|
101
|
+
|`Number`|The numerator of the rational number|
|
|
102
|
+
|
|
103
|
+
### Rational.**denominator**
|
|
104
|
+
|
|
105
|
+
<details disabled>
|
|
106
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
107
|
+
No other changes yet.
|
|
108
|
+
</details>
|
|
109
|
+
|
|
110
|
+
```grain
|
|
111
|
+
denominator : (x: Rational) => Number
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Finds the denominator of the rational number.
|
|
115
|
+
|
|
116
|
+
Parameters:
|
|
117
|
+
|
|
118
|
+
|param|type|description|
|
|
119
|
+
|-----|----|-----------|
|
|
120
|
+
|`x`|`Rational`|The rational number to inspect|
|
|
121
|
+
|
|
122
|
+
Returns:
|
|
123
|
+
|
|
124
|
+
|type|description|
|
|
125
|
+
|----|-----------|
|
|
126
|
+
|`Number`|The denominator of the rational number|
|
|
127
|
+
|
|
128
|
+
### Rational.**toIntegerRatio**
|
|
129
|
+
|
|
130
|
+
<details disabled>
|
|
131
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
132
|
+
No other changes yet.
|
|
133
|
+
</details>
|
|
134
|
+
|
|
135
|
+
```grain
|
|
136
|
+
toIntegerRatio : (x: Rational) => (Number, Number)
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Gets the numerator and denominator of the rational.
|
|
140
|
+
|
|
141
|
+
Parameters:
|
|
142
|
+
|
|
143
|
+
|param|type|description|
|
|
144
|
+
|-----|----|-----------|
|
|
145
|
+
|`x`|`Rational`|The rational to split|
|
|
146
|
+
|
|
147
|
+
Returns:
|
|
148
|
+
|
|
149
|
+
|type|description|
|
|
150
|
+
|----|-----------|
|
|
151
|
+
|`(Number, Number)`|The numerator and denominator of the rational|
|
|
152
|
+
|
|
153
|
+
Examples:
|
|
154
|
+
|
|
155
|
+
```grain
|
|
156
|
+
Rational.toIntegerRatio(1/2r) == (1, 2)
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
```grain
|
|
160
|
+
Rational.toIntegerRatio(2/8r) == (1, 4)
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Rational.**fromIntegerRatio**
|
|
164
|
+
|
|
165
|
+
<details disabled>
|
|
166
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
167
|
+
No other changes yet.
|
|
168
|
+
</details>
|
|
169
|
+
|
|
170
|
+
```grain
|
|
171
|
+
fromIntegerRatio : (numerator: Number, denominator: Number) => Rational
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Creates a rational from a numerator and denominator.
|
|
175
|
+
|
|
176
|
+
Parameters:
|
|
177
|
+
|
|
178
|
+
|param|type|description|
|
|
179
|
+
|-----|----|-----------|
|
|
180
|
+
|`numerator`|`Number`|The numerator|
|
|
181
|
+
|`denominator`|`Number`|The denominator|
|
|
182
|
+
|
|
183
|
+
Returns:
|
|
184
|
+
|
|
185
|
+
|type|description|
|
|
186
|
+
|----|-----------|
|
|
187
|
+
|`Rational`|The reduced rational|
|
|
188
|
+
|
|
189
|
+
Throws:
|
|
190
|
+
|
|
191
|
+
`InvalidArgument(String)`
|
|
192
|
+
|
|
193
|
+
* If the numerator is not an integer
|
|
194
|
+
* If the denominator is not an integer
|
|
195
|
+
|
|
196
|
+
Examples:
|
|
197
|
+
|
|
198
|
+
```grain
|
|
199
|
+
Rational.fromIntegerRatio(1, 2) == 1/2r
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
```grain
|
|
203
|
+
Rational.fromIntegerRatio(2, 8) == 1/4r
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### Rational.**(+)**
|
|
207
|
+
|
|
208
|
+
<details disabled>
|
|
209
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
210
|
+
No other changes yet.
|
|
211
|
+
</details>
|
|
212
|
+
|
|
213
|
+
```grain
|
|
214
|
+
(+) : (x: Rational, y: Rational) => Rational
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
Computes the sum of its operands.
|
|
218
|
+
|
|
219
|
+
Parameters:
|
|
220
|
+
|
|
221
|
+
|param|type|description|
|
|
222
|
+
|-----|----|-----------|
|
|
223
|
+
|`x`|`Rational`|The first operand|
|
|
224
|
+
|`y`|`Rational`|The second operand|
|
|
225
|
+
|
|
226
|
+
Returns:
|
|
227
|
+
|
|
228
|
+
|type|description|
|
|
229
|
+
|----|-----------|
|
|
230
|
+
|`Rational`|The sum of the two operands|
|
|
231
|
+
|
|
232
|
+
Examples:
|
|
233
|
+
|
|
234
|
+
```grain
|
|
235
|
+
use Rational.{ (+) }
|
|
236
|
+
assert 1/2r + 1/4r == 3/4r
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### Rational.**(-)**
|
|
240
|
+
|
|
241
|
+
<details disabled>
|
|
242
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
243
|
+
No other changes yet.
|
|
244
|
+
</details>
|
|
245
|
+
|
|
246
|
+
```grain
|
|
247
|
+
(-) : (x: Rational, y: Rational) => Rational
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
Computes the difference of its operands.
|
|
251
|
+
|
|
252
|
+
Parameters:
|
|
253
|
+
|
|
254
|
+
|param|type|description|
|
|
255
|
+
|-----|----|-----------|
|
|
256
|
+
|`x`|`Rational`|The first operand|
|
|
257
|
+
|`y`|`Rational`|The second operand|
|
|
258
|
+
|
|
259
|
+
Returns:
|
|
260
|
+
|
|
261
|
+
|type|description|
|
|
262
|
+
|----|-----------|
|
|
263
|
+
|`Rational`|The difference of the two operands|
|
|
264
|
+
|
|
265
|
+
Examples:
|
|
266
|
+
|
|
267
|
+
```grain
|
|
268
|
+
use Rational.{ (-) }
|
|
269
|
+
assert 1/2r - 1/4r == 1/4r
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### Rational.**(*)**
|
|
273
|
+
|
|
274
|
+
<details disabled>
|
|
275
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
276
|
+
No other changes yet.
|
|
277
|
+
</details>
|
|
278
|
+
|
|
279
|
+
```grain
|
|
280
|
+
(*) : (x: Rational, y: Rational) => Rational
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
Computes the product of its operands.
|
|
284
|
+
|
|
285
|
+
Parameters:
|
|
286
|
+
|
|
287
|
+
|param|type|description|
|
|
288
|
+
|-----|----|-----------|
|
|
289
|
+
|`x`|`Rational`|The first operand|
|
|
290
|
+
|`y`|`Rational`|The second operand|
|
|
291
|
+
|
|
292
|
+
Returns:
|
|
293
|
+
|
|
294
|
+
|type|description|
|
|
295
|
+
|----|-----------|
|
|
296
|
+
|`Rational`|The product of the two operands|
|
|
297
|
+
|
|
298
|
+
Examples:
|
|
299
|
+
|
|
300
|
+
```grain
|
|
301
|
+
use Rational.{ (*) }
|
|
302
|
+
assert 1/2r * 1/4r == 1/8r
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
### Rational.**(/)**
|
|
306
|
+
|
|
307
|
+
<details disabled>
|
|
308
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
309
|
+
No other changes yet.
|
|
310
|
+
</details>
|
|
311
|
+
|
|
312
|
+
```grain
|
|
313
|
+
(/) : (x: Rational, y: Rational) => Rational
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
Computes the quotient of its operands.
|
|
317
|
+
|
|
318
|
+
Parameters:
|
|
319
|
+
|
|
320
|
+
|param|type|description|
|
|
321
|
+
|-----|----|-----------|
|
|
322
|
+
|`x`|`Rational`|The first operand|
|
|
323
|
+
|`y`|`Rational`|The second operand|
|
|
324
|
+
|
|
325
|
+
Returns:
|
|
326
|
+
|
|
327
|
+
|type|description|
|
|
328
|
+
|----|-----------|
|
|
329
|
+
|`Rational`|The quotient of the two operands|
|
|
330
|
+
|
|
331
|
+
Examples:
|
|
332
|
+
|
|
333
|
+
```grain
|
|
334
|
+
use Rational.{ (/) }
|
|
335
|
+
assert 1/2r / 1/4r == 2/1r
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
### Rational.**(==)**
|
|
339
|
+
|
|
340
|
+
<details disabled>
|
|
341
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
342
|
+
No other changes yet.
|
|
343
|
+
</details>
|
|
344
|
+
|
|
345
|
+
```grain
|
|
346
|
+
(==) : (x: Rational, y: Rational) => Bool
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
Checks if the first value is equal to the second value.
|
|
350
|
+
|
|
351
|
+
Parameters:
|
|
352
|
+
|
|
353
|
+
|param|type|description|
|
|
354
|
+
|-----|----|-----------|
|
|
355
|
+
|`x`|`Rational`|The first value|
|
|
356
|
+
|`y`|`Rational`|The second value|
|
|
357
|
+
|
|
358
|
+
Returns:
|
|
359
|
+
|
|
360
|
+
|type|description|
|
|
361
|
+
|----|-----------|
|
|
362
|
+
|`Bool`|`true` if the first value is equal to the second value or `false` otherwise|
|
|
363
|
+
|
|
364
|
+
Examples:
|
|
365
|
+
|
|
366
|
+
```grain
|
|
367
|
+
use Rational.{ (==) }
|
|
368
|
+
assert 1/2r == 1/2r
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
### Rational.**(!=)**
|
|
372
|
+
|
|
373
|
+
<details disabled>
|
|
374
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
375
|
+
No other changes yet.
|
|
376
|
+
</details>
|
|
377
|
+
|
|
378
|
+
```grain
|
|
379
|
+
(!=) : (x: Rational, y: Rational) => Bool
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
Checks if the first value is not equal to the second value.
|
|
383
|
+
|
|
384
|
+
Parameters:
|
|
385
|
+
|
|
386
|
+
|param|type|description|
|
|
387
|
+
|-----|----|-----------|
|
|
388
|
+
|`x`|`Rational`|The first value|
|
|
389
|
+
|`y`|`Rational`|The second value|
|
|
390
|
+
|
|
391
|
+
Returns:
|
|
392
|
+
|
|
393
|
+
|type|description|
|
|
394
|
+
|----|-----------|
|
|
395
|
+
|`Bool`|`true` if the first value is not equal to the second value or `false` otherwise|
|
|
396
|
+
|
|
397
|
+
Examples:
|
|
398
|
+
|
|
399
|
+
```grain
|
|
400
|
+
use Rational.{ (!=) }
|
|
401
|
+
assert 1/2r != 1/4r
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
### Rational.**(<)**
|
|
405
|
+
|
|
406
|
+
<details disabled>
|
|
407
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
408
|
+
No other changes yet.
|
|
409
|
+
</details>
|
|
410
|
+
|
|
411
|
+
```grain
|
|
412
|
+
(<) : (x: Rational, y: Rational) => Bool
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
Checks if the first value is less than the second value.
|
|
416
|
+
|
|
417
|
+
Parameters:
|
|
418
|
+
|
|
419
|
+
|param|type|description|
|
|
420
|
+
|-----|----|-----------|
|
|
421
|
+
|`x`|`Rational`|The first value|
|
|
422
|
+
|`y`|`Rational`|The second value|
|
|
423
|
+
|
|
424
|
+
Returns:
|
|
425
|
+
|
|
426
|
+
|type|description|
|
|
427
|
+
|----|-----------|
|
|
428
|
+
|`Bool`|`true` if the first value is less than the second value or `false` otherwise|
|
|
429
|
+
|
|
430
|
+
Examples:
|
|
431
|
+
|
|
432
|
+
```grain
|
|
433
|
+
use Rational.{ (<) }
|
|
434
|
+
assert 1/4r < 1/2r
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
### Rational.**(>)**
|
|
438
|
+
|
|
439
|
+
<details disabled>
|
|
440
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
441
|
+
No other changes yet.
|
|
442
|
+
</details>
|
|
443
|
+
|
|
444
|
+
```grain
|
|
445
|
+
(>) : (x: Rational, y: Rational) => Bool
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
Checks if the first value is greater than the second value.
|
|
449
|
+
|
|
450
|
+
Parameters:
|
|
451
|
+
|
|
452
|
+
|param|type|description|
|
|
453
|
+
|-----|----|-----------|
|
|
454
|
+
|`x`|`Rational`|The first value|
|
|
455
|
+
|`y`|`Rational`|The second value|
|
|
456
|
+
|
|
457
|
+
Returns:
|
|
458
|
+
|
|
459
|
+
|type|description|
|
|
460
|
+
|----|-----------|
|
|
461
|
+
|`Bool`|`true` if the first value is greater than the second value or `false` otherwise|
|
|
462
|
+
|
|
463
|
+
Examples:
|
|
464
|
+
|
|
465
|
+
```grain
|
|
466
|
+
use Rational.{ (>) }
|
|
467
|
+
assert 1/2r > 1/4r
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
### Rational.**(<=)**
|
|
471
|
+
|
|
472
|
+
<details disabled>
|
|
473
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
474
|
+
No other changes yet.
|
|
475
|
+
</details>
|
|
476
|
+
|
|
477
|
+
```grain
|
|
478
|
+
(<=) : (x: Rational, y: Rational) => Bool
|
|
479
|
+
```
|
|
480
|
+
|
|
481
|
+
Checks if the first value is less than or equal to the second value.
|
|
482
|
+
|
|
483
|
+
Parameters:
|
|
484
|
+
|
|
485
|
+
|param|type|description|
|
|
486
|
+
|-----|----|-----------|
|
|
487
|
+
|`x`|`Rational`|The first value|
|
|
488
|
+
|`y`|`Rational`|The second value|
|
|
489
|
+
|
|
490
|
+
Returns:
|
|
491
|
+
|
|
492
|
+
|type|description|
|
|
493
|
+
|----|-----------|
|
|
494
|
+
|`Bool`|`true` if the first value is less than or equal to the second value or `false` otherwise|
|
|
495
|
+
|
|
496
|
+
Examples:
|
|
497
|
+
|
|
498
|
+
```grain
|
|
499
|
+
use Rational.{ (<=) }
|
|
500
|
+
assert 1/4r <= 1/2r
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
```grain
|
|
504
|
+
use Rational.{ (<=) }
|
|
505
|
+
assert 1/2r <= 1/2r
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
### Rational.**(>=)**
|
|
509
|
+
|
|
510
|
+
<details disabled>
|
|
511
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
512
|
+
No other changes yet.
|
|
513
|
+
</details>
|
|
514
|
+
|
|
515
|
+
```grain
|
|
516
|
+
(>=) : (x: Rational, y: Rational) => Bool
|
|
517
|
+
```
|
|
518
|
+
|
|
519
|
+
Checks if the first value is greater than or equal to the second value.
|
|
520
|
+
|
|
521
|
+
Parameters:
|
|
522
|
+
|
|
523
|
+
|param|type|description|
|
|
524
|
+
|-----|----|-----------|
|
|
525
|
+
|`x`|`Rational`|The first value|
|
|
526
|
+
|`y`|`Rational`|The second value|
|
|
527
|
+
|
|
528
|
+
Returns:
|
|
529
|
+
|
|
530
|
+
|type|description|
|
|
531
|
+
|----|-----------|
|
|
532
|
+
|`Bool`|`true` if the first value is greater than or equal to the second value or `false` otherwise|
|
|
533
|
+
|
|
534
|
+
Examples:
|
|
535
|
+
|
|
536
|
+
```grain
|
|
537
|
+
use Rational.{ (>=) }
|
|
538
|
+
assert 1/2r >= 1/4r
|
|
539
|
+
```
|
|
540
|
+
|
|
541
|
+
```grain
|
|
542
|
+
use Rational.{ (>=) }
|
|
543
|
+
assert 1/2r >= 1/2r
|
|
544
|
+
```
|
|
545
|
+
|