@grain/stdlib 0.4.5 → 0.5.1
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 +87 -0
- package/LICENSE +1 -1
- package/array.gr +18 -18
- package/array.md +18 -18
- package/bigint.gr +497 -0
- package/bigint.md +811 -0
- package/buffer.gr +49 -213
- package/buffer.md +24 -17
- package/bytes.gr +100 -202
- package/bytes.md +19 -0
- package/char.gr +63 -133
- package/exception.md +6 -0
- package/float32.gr +159 -82
- package/float32.md +315 -0
- package/float64.gr +163 -82
- package/float64.md +315 -0
- package/hash.gr +37 -37
- package/int32.gr +479 -230
- package/int32.md +937 -0
- package/int64.gr +479 -230
- package/int64.md +937 -0
- package/list.gr +467 -70
- package/list.md +1141 -0
- package/map.gr +192 -7
- package/map.md +525 -0
- package/number.gr +30 -54
- package/number.md +3 -3
- package/option.md +1 -1
- package/package.json +3 -3
- package/pervasives.gr +499 -59
- package/pervasives.md +1116 -0
- package/queue.gr +4 -0
- package/queue.md +10 -0
- package/random.gr +196 -0
- package/random.md +179 -0
- package/regex.gr +1833 -842
- package/regex.md +11 -11
- package/result.md +1 -1
- package/runtime/bigint.gr +2045 -0
- package/runtime/bigint.md +326 -0
- package/runtime/dataStructures.gr +99 -278
- package/runtime/dataStructures.md +391 -0
- package/runtime/debug.md +6 -0
- package/runtime/equal.gr +5 -23
- package/runtime/equal.md +6 -0
- package/runtime/exception.md +30 -0
- package/runtime/gc.gr +20 -3
- package/runtime/gc.md +36 -0
- package/runtime/malloc.gr +13 -11
- package/runtime/malloc.md +55 -0
- package/runtime/numberUtils.gr +93 -41
- package/runtime/numberUtils.md +54 -0
- package/runtime/numbers.gr +1043 -391
- package/runtime/numbers.md +300 -0
- package/runtime/string.gr +136 -230
- package/runtime/string.md +24 -0
- package/runtime/stringUtils.gr +58 -38
- package/runtime/stringUtils.md +6 -0
- package/runtime/unsafe/constants.gr +17 -0
- package/runtime/unsafe/constants.md +72 -0
- package/runtime/unsafe/conv.md +71 -0
- package/runtime/unsafe/errors.md +204 -0
- package/runtime/unsafe/memory.md +54 -0
- package/runtime/unsafe/printWasm.md +24 -0
- package/runtime/unsafe/tags.gr +9 -8
- package/runtime/unsafe/tags.md +120 -0
- package/runtime/unsafe/wasmf32.md +168 -0
- package/runtime/unsafe/wasmf64.md +168 -0
- package/runtime/unsafe/wasmi32.md +282 -0
- package/runtime/unsafe/wasmi64.md +300 -0
- package/runtime/utils/printing.gr +62 -0
- package/runtime/utils/printing.md +18 -0
- package/runtime/wasi.gr +1 -1
- package/runtime/wasi.md +839 -0
- package/set.gr +17 -8
- package/set.md +24 -21
- package/stack.gr +3 -3
- package/stack.md +4 -6
- package/string.gr +196 -331
- package/string.md +3 -3
- package/sys/file.gr +246 -430
- package/sys/process.gr +27 -45
- package/sys/random.gr +47 -16
- package/sys/random.md +38 -0
- package/sys/time.gr +11 -27
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,92 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
### [0.5.1](https://github.com/grain-lang/grain/compare/stdlib-v0.5.0...stdlib-v0.5.1) (2022-06-08)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Miscellaneous Chores
|
|
7
|
+
|
|
8
|
+
* **stdlib:** Synchronize Grain versions
|
|
9
|
+
|
|
10
|
+
## [0.5.0](https://github.com/grain-lang/grain/compare/stdlib-v0.4.6...stdlib-v0.5.0) (2022-06-05)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### ⚠ BREAKING CHANGES
|
|
14
|
+
|
|
15
|
+
* **stdlib:** Use explicit exports for Pervasives (#1301)
|
|
16
|
+
* **stdlib:** Remove `sum` function from the List module (#1300)
|
|
17
|
+
* **stdlib:** Ensure Void return for forEach functions in List module (#1307)
|
|
18
|
+
* **stdlib:** Provide correct types for BigInt operations (#1297)
|
|
19
|
+
* **grainfmt:** Replace `--in-place` flag with `-o` flag
|
|
20
|
+
* **grainfmt:** Remove stdin formatting support
|
|
21
|
+
* **compiler:** Arbitrary-Precision Integer Arithmetic (#1167)
|
|
22
|
+
* Drop node 14 support (#1092)
|
|
23
|
+
* **stdlib:** Add explicit void return type on Set.forEach (#1225)
|
|
24
|
+
* **stdlib:** Add explicit void return type on Map.forEach (#1220)
|
|
25
|
+
* **stdlib:** Add type aliases to regex lib (#1036)
|
|
26
|
+
* **compiler:** Stack-allocated Chars (#1103)
|
|
27
|
+
* **stdlib:** Align Buffer's `addStringSlice` API with String's `slice` (#1136)
|
|
28
|
+
* **graindoc:** Add `--current-version` flag, required for since/history attributes (#1116)
|
|
29
|
+
* **compiler:** Remove decRefIgnoreZeros (#1068)
|
|
30
|
+
* **compiler:** Add `--memory-base` flag (#1115)
|
|
31
|
+
* **compiler:** Re-implement Grain parser (#1033)
|
|
32
|
+
|
|
33
|
+
### Features
|
|
34
|
+
|
|
35
|
+
* **compiler:** Add `--memory-base` flag ([#1115](https://github.com/grain-lang/grain/issues/1115)) ([0680826](https://github.com/grain-lang/grain/commit/068082663c4387c3ab54c052869e9b9a06b87e26))
|
|
36
|
+
* **compiler:** Arbitrary-Precision Integer Arithmetic ([#1167](https://github.com/grain-lang/grain/issues/1167)) ([6f34de2](https://github.com/grain-lang/grain/commit/6f34de214b28358ea1df553685fa3a19336ddba9))
|
|
37
|
+
* **compiler:** Call known functions across module boundaries ([#1175](https://github.com/grain-lang/grain/issues/1175)) ([b2d7440](https://github.com/grain-lang/grain/commit/b2d744034ec7e0601554531c910e9d0f5451d464))
|
|
38
|
+
* **compiler:** Convert `runtime/dataStructures.gr` to primitives ([#1145](https://github.com/grain-lang/grain/issues/1145)) ([2d43b28](https://github.com/grain-lang/grain/commit/2d43b286141df75f6b92300e48d2bc4804014872))
|
|
39
|
+
* **compiler:** Convert Sys libraries to [@unsafe](https://github.com/unsafe) ([#1272](https://github.com/grain-lang/grain/issues/1272)) ([fcdfc2a](https://github.com/grain-lang/grain/commit/fcdfc2a815be889d5f0424a04dd5b2373dbd983b))
|
|
40
|
+
* **compiler:** Don't close over global values ([#1134](https://github.com/grain-lang/grain/issues/1134)) ([e8caec6](https://github.com/grain-lang/grain/commit/e8caec6c2a5892e955c8827b18d8d436bebe6073))
|
|
41
|
+
* **compiler:** Re-implement Grain parser ([#1033](https://github.com/grain-lang/grain/issues/1033)) ([9dc3c96](https://github.com/grain-lang/grain/commit/9dc3c96f87a0b2affe9db36e1b03360d198f79f1))
|
|
42
|
+
* **compiler:** Stack-allocated Chars ([#1103](https://github.com/grain-lang/grain/issues/1103)) ([095385e](https://github.com/grain-lang/grain/commit/095385e7c67bbc7a417a21acaf6f1c498c75ce63))
|
|
43
|
+
* **graindoc:** Add `--current-version` flag, required for since/history attributes ([#1116](https://github.com/grain-lang/grain/issues/1116)) ([0f681ea](https://github.com/grain-lang/grain/commit/0f681ea140749395f3ce99a460f30778537183ac))
|
|
44
|
+
* **graindoc:** Allow directory input & output ([#1263](https://github.com/grain-lang/grain/issues/1263)) ([d4cb8ab](https://github.com/grain-lang/grain/commit/d4cb8abcb4accafeb3cae0bac77eee9a365e464d))
|
|
45
|
+
* **grainfmt:** Allow directory input & output ([#1274](https://github.com/grain-lang/grain/issues/1274)) ([d3e7a33](https://github.com/grain-lang/grain/commit/d3e7a33b01352a9c2bcc3b17a5b2995451d92221))
|
|
46
|
+
* **grainfmt:** Replace `--in-place` flag with `-o` flag ([d3e7a33](https://github.com/grain-lang/grain/commit/d3e7a33b01352a9c2bcc3b17a5b2995451d92221))
|
|
47
|
+
* **stdlib:** Add module for pseudo-random number generation ([#921](https://github.com/grain-lang/grain/issues/921)) ([db1fa4e](https://github.com/grain-lang/grain/commit/db1fa4e491d35bb582beaba12157884647384a77))
|
|
48
|
+
* **stdlib:** Add unsigned versions of Int32/Int64 comparison operations ([#831](https://github.com/grain-lang/grain/issues/831)) ([5f20868](https://github.com/grain-lang/grain/commit/5f20868e7b6e3f52d62c8531d99d1130ca84961e))
|
|
49
|
+
* **stdlib:** Added Bytes.clear function. Avoid allocation in Buffer.clear ([#1124](https://github.com/grain-lang/grain/issues/1124)) ([4afd17a](https://github.com/grain-lang/grain/commit/4afd17a91e59027fa7af0fe58977bdbe942f8072))
|
|
50
|
+
* **stdlib:** Convert runtime printing utils to [@unsafe](https://github.com/unsafe) ([#1135](https://github.com/grain-lang/grain/issues/1135)) ([403e1d2](https://github.com/grain-lang/grain/commit/403e1d20e2082fe2dcd2721f83f6c2b36d4154bf))
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
### Bug Fixes
|
|
54
|
+
|
|
55
|
+
* **cli:** Ensure parent flags are inherited by the format command ([d3e7a33](https://github.com/grain-lang/grain/commit/d3e7a33b01352a9c2bcc3b17a5b2995451d92221))
|
|
56
|
+
* **graindoc:** Add parens around infix operators in titles ([#1303](https://github.com/grain-lang/grain/issues/1303)) ([acba9c1](https://github.com/grain-lang/grain/commit/acba9c1757688756c3ca98b22a0a159b8d8f9e7d))
|
|
57
|
+
* **graindoc:** Preserve indentation in Doc comments during trim ([#1119](https://github.com/grain-lang/grain/issues/1119)) ([b8a6d57](https://github.com/grain-lang/grain/commit/b8a6d57cce274bfbc2cc16c5b25215b042d4264c))
|
|
58
|
+
* **graindoc:** Remove spaces between parens and infix idents ([#1302](https://github.com/grain-lang/grain/issues/1302)) ([95e596f](https://github.com/grain-lang/grain/commit/95e596fa3fdae5a8a0e07d76ff8c11eeab99e8d7))
|
|
59
|
+
* **graindoc:** Use value_descriptions and type_declarations defined by the module signature ([#1241](https://github.com/grain-lang/grain/issues/1241)) ([5896242](https://github.com/grain-lang/grain/commit/5896242c324622f3329c144bd2c9642aade9d049))
|
|
60
|
+
* **grainfmt:** Remove parens around annotated types ([#1109](https://github.com/grain-lang/grain/issues/1109)) ([0ca66bd](https://github.com/grain-lang/grain/commit/0ca66bd43703826f86ef5b28b49d250af219fb0b))
|
|
61
|
+
* **stdlib:** Add explicit void return type on Map.forEach ([#1220](https://github.com/grain-lang/grain/issues/1220)) ([ab2066a](https://github.com/grain-lang/grain/commit/ab2066aadffa8813344d9df7c7a10ec0f76751b6))
|
|
62
|
+
* **stdlib:** Add explicit void return type on Set.forEach ([#1225](https://github.com/grain-lang/grain/issues/1225)) ([694e6cf](https://github.com/grain-lang/grain/commit/694e6cf8fcd061a77b2915dc0ea9e9b1ae143ae4))
|
|
63
|
+
* **stdlib:** Align Buffer's `addStringSlice` API with String's `slice` ([#1136](https://github.com/grain-lang/grain/issues/1136)) ([0c7cb82](https://github.com/grain-lang/grain/commit/0c7cb820d49cda74598680cc614c0d893b4d2b40))
|
|
64
|
+
* **stdlib:** Buffer.toBytes should not expose the raw instance of Bytes used by the buffer ([#1130](https://github.com/grain-lang/grain/issues/1130)) ([d2bb585](https://github.com/grain-lang/grain/commit/d2bb585d3e2092f1331a679f4e84a9500b8c87a5))
|
|
65
|
+
* **stdlib:** Ensure Void return for forEach functions in List module ([#1307](https://github.com/grain-lang/grain/issues/1307)) ([31f480c](https://github.com/grain-lang/grain/commit/31f480c22e0a39b347fc3a48e1d0b5bd40c2f19e))
|
|
66
|
+
* **stdlib:** Fix float printing in dtoa ([#1165](https://github.com/grain-lang/grain/issues/1165)) ([2987210](https://github.com/grain-lang/grain/commit/2987210648873ab474990ff2b7146a489fecb268))
|
|
67
|
+
* **stdlib:** Fixed a memory leak in Buffer.addStringSlice. ([#1122](https://github.com/grain-lang/grain/issues/1122)) ([c4e1911](https://github.com/grain-lang/grain/commit/c4e19110bd9923e58a7953fcbcef18bf07f3efd6))
|
|
68
|
+
* **stdlib:** Fixed length and byteLength for strings over 2GiB. ([#1126](https://github.com/grain-lang/grain/issues/1126)) ([08a9487](https://github.com/grain-lang/grain/commit/08a948709270a9aa4ac853c2887bc652c4734f36))
|
|
69
|
+
* **stdlib:** Make Bytes.length handle sizes over 2GiB ([#1123](https://github.com/grain-lang/grain/issues/1123)) ([d7386eb](https://github.com/grain-lang/grain/commit/d7386eb36c32452d69a734b447015b4db23f1ac4))
|
|
70
|
+
* **stdlib:** Provide correct types for BigInt operations ([#1297](https://github.com/grain-lang/grain/issues/1297)) ([fdd2f1c](https://github.com/grain-lang/grain/commit/fdd2f1c49b938a013d6ae199b5e662cb93d051e6))
|
|
71
|
+
* **stdlib:** Remove intermediate resizes in Buffer.autogrow ([#1125](https://github.com/grain-lang/grain/issues/1125)) ([c1695d0](https://github.com/grain-lang/grain/commit/c1695d066ccd40b3118c5c870353addeef67bfc1))
|
|
72
|
+
* **stdlib:** Use explicit exports for Pervasives ([#1301](https://github.com/grain-lang/grain/issues/1301)) ([bad5897](https://github.com/grain-lang/grain/commit/bad5897062444ec4d4ace805adcd382725b86125))
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
### Miscellaneous Chores
|
|
76
|
+
|
|
77
|
+
* **compiler:** Remove decRefIgnoreZeros ([#1068](https://github.com/grain-lang/grain/issues/1068)) ([3ae8eaa](https://github.com/grain-lang/grain/commit/3ae8eaabad4467304c500c2f0cc9c40749d8513b))
|
|
78
|
+
* Drop node 14 support ([#1092](https://github.com/grain-lang/grain/issues/1092)) ([ef4358f](https://github.com/grain-lang/grain/commit/ef4358ff7de14a35edf3e971e04513d497fe1574))
|
|
79
|
+
* **grainfmt:** Remove stdin formatting support ([d3e7a33](https://github.com/grain-lang/grain/commit/d3e7a33b01352a9c2bcc3b17a5b2995451d92221))
|
|
80
|
+
* **stdlib:** Add type aliases to regex lib ([#1036](https://github.com/grain-lang/grain/issues/1036)) ([a926ea5](https://github.com/grain-lang/grain/commit/a926ea5cafa18e46487a585abbdf5460b15b4f48))
|
|
81
|
+
* **stdlib:** Remove `sum` function from the List module ([#1300](https://github.com/grain-lang/grain/issues/1300)) ([9101615](https://github.com/grain-lang/grain/commit/9101615688f20310ae32573f93f36cfcf5c69be1))
|
|
82
|
+
|
|
83
|
+
### [0.4.6](https://www.github.com/grain-lang/grain/compare/stdlib-v0.4.5...stdlib-v0.4.6) (2022-01-17)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
### Bug Fixes
|
|
87
|
+
|
|
88
|
+
* **grainfmt:** Indent function application args when adding parens ([#1095](https://www.github.com/grain-lang/grain/issues/1095)) ([64af7d3](https://www.github.com/grain-lang/grain/commit/64af7d387dca2fddb9b3d190ccdf5790ec3d8e65))
|
|
89
|
+
|
|
3
90
|
### [0.4.5](https://www.github.com/grain-lang/grain/compare/stdlib-v0.4.4...stdlib-v0.4.5) (2021-12-31)
|
|
4
91
|
|
|
5
92
|
|
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2017-
|
|
3
|
+
Copyright (c) 2017-2022 Oscar Spencer <oscar@grain-lang.org> and Philip Blair <philip@grain-lang.org>
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/array.gr
CHANGED
|
@@ -43,7 +43,7 @@ let initLength = length => {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
|
-
*
|
|
46
|
+
* Provides the length of the input array.
|
|
47
47
|
*
|
|
48
48
|
* @param array: The array to inspect
|
|
49
49
|
* @returns The number of elements in the array
|
|
@@ -52,7 +52,7 @@ let initLength = length => {
|
|
|
52
52
|
*/
|
|
53
53
|
@disableGC
|
|
54
54
|
export let rec length = array => {
|
|
55
|
-
let ptr = WasmI32.fromGrain(array:
|
|
55
|
+
let ptr = WasmI32.fromGrain(array: Array<a>)
|
|
56
56
|
let ret = tagSimpleNumber(WasmI32.load(ptr, _ARRAY_LENGTH_OFFSET))
|
|
57
57
|
Memory.decRef(ptr)
|
|
58
58
|
Memory.decRef(WasmI32.fromGrain(length))
|
|
@@ -89,7 +89,7 @@ export let rec make /*: (Number, a) -> Array<a>*/ =
|
|
|
89
89
|
_ARRAY_START_OFFSET
|
|
90
90
|
)
|
|
91
91
|
}
|
|
92
|
-
let ret = WasmI32.toGrain(array):
|
|
92
|
+
let ret = WasmI32.toGrain(array): Array<a>
|
|
93
93
|
Memory.decRef(WasmI32.fromGrain(lengthArg))
|
|
94
94
|
Memory.decRef(WasmI32.fromGrain(item))
|
|
95
95
|
Memory.decRef(WasmI32.fromGrain(make))
|
|
@@ -105,7 +105,7 @@ export let rec make /*: (Number, a) -> Array<a>*/ =
|
|
|
105
105
|
* @param fn: The initializer function to call with each index, where the value returned will be used to initialize the element
|
|
106
106
|
* @returns The new array
|
|
107
107
|
*
|
|
108
|
-
* @example Array.init(5, n => n + 3) // [>
|
|
108
|
+
* @example Array.init(5, n => n + 3) // [> 3, 4, 5, 6, 7]
|
|
109
109
|
*
|
|
110
110
|
* @since v0.1.0
|
|
111
111
|
*/
|
|
@@ -133,7 +133,7 @@ export let rec init /*: (Number, Number -> a) -> Array<a>*/ =
|
|
|
133
133
|
}
|
|
134
134
|
Memory.decRef(WasmI32.fromGrain(fn))
|
|
135
135
|
Memory.decRef(WasmI32.fromGrain(init))
|
|
136
|
-
WasmI32.toGrain(array):
|
|
136
|
+
WasmI32.toGrain(array): Array<a>
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
/**
|
|
@@ -171,8 +171,8 @@ export let set = (index, value, array) => {
|
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
/**
|
|
174
|
-
* Creates a new array with the
|
|
175
|
-
* the
|
|
174
|
+
* Creates a new array with the elements of the first array followed by
|
|
175
|
+
* the elements of the second array. This does not modify the arguments.
|
|
176
176
|
*
|
|
177
177
|
* @param array1: The array containing elements to appear first
|
|
178
178
|
* @param array2: The array containing elements to appear second
|
|
@@ -283,7 +283,7 @@ export let forEach = (fn, array) => {
|
|
|
283
283
|
}
|
|
284
284
|
|
|
285
285
|
/**
|
|
286
|
-
* Iterates an array, calling an iterator function
|
|
286
|
+
* Iterates an array, calling an iterator function on each element.
|
|
287
287
|
* Also passes the index as the second argument to the function.
|
|
288
288
|
*
|
|
289
289
|
* @param fn: The iterator function to call with each element
|
|
@@ -403,7 +403,7 @@ export let flatMap = (fn, array) => {
|
|
|
403
403
|
*
|
|
404
404
|
* @param fn: The function to call on each element, where the returned value indicates if the element satisfies the condition
|
|
405
405
|
* @param array: The array to check
|
|
406
|
-
* @returns `true` if all elements satify the condition
|
|
406
|
+
* @returns `true` if all elements satify the condition or `false` otherwise
|
|
407
407
|
*
|
|
408
408
|
* @since v0.3.0
|
|
409
409
|
*/
|
|
@@ -415,11 +415,11 @@ export let every = (fn, array) => {
|
|
|
415
415
|
|
|
416
416
|
/**
|
|
417
417
|
* Checks that the given condition is satisfied **at least
|
|
418
|
-
* once** by an
|
|
418
|
+
* once** by an element in the input array.
|
|
419
419
|
*
|
|
420
420
|
* @param fn: The function to call on each element, where the returned value indicates if the element satisfies the condition
|
|
421
421
|
* @param array: The array to iterate
|
|
422
|
-
* @returns `true` if one or more elements satify the condition
|
|
422
|
+
* @returns `true` if one or more elements satify the condition or `false` otherwise
|
|
423
423
|
*
|
|
424
424
|
* @since v0.3.0
|
|
425
425
|
*/
|
|
@@ -549,8 +549,8 @@ export let fromList = list => {
|
|
|
549
549
|
* Uses the generic `==` structural equality operator.
|
|
550
550
|
*
|
|
551
551
|
* @param search: The value to compare
|
|
552
|
-
* @param array: The array to
|
|
553
|
-
* @returns `true` if the value exists in the array
|
|
552
|
+
* @param array: The array to inspect
|
|
553
|
+
* @returns `true` if the value exists in the array or `false` otherwise
|
|
554
554
|
*
|
|
555
555
|
* @since v0.2.0
|
|
556
556
|
*/
|
|
@@ -569,7 +569,7 @@ export let contains = (search, array) => {
|
|
|
569
569
|
*
|
|
570
570
|
* @param fn: The function to call on each element, where the returned value indicates if the element satisfies the condition
|
|
571
571
|
* @param array: The array to search
|
|
572
|
-
* @returns `Some(element)` containing the first value found
|
|
572
|
+
* @returns `Some(element)` containing the first value found or `None` otherwise
|
|
573
573
|
*
|
|
574
574
|
* @since v0.2.0
|
|
575
575
|
*/
|
|
@@ -603,7 +603,7 @@ export let find = (fn, array) => {
|
|
|
603
603
|
*
|
|
604
604
|
* @param fn: The function to call on each element, where the returned value indicates if the element satisfies the condition
|
|
605
605
|
* @param array: The array to search
|
|
606
|
-
* @returns `Some(index)` containing the index of the first element found
|
|
606
|
+
* @returns `Some(index)` containing the index of the first element found or `None` otherwise
|
|
607
607
|
*
|
|
608
608
|
* @since v0.2.0
|
|
609
609
|
*/
|
|
@@ -917,10 +917,10 @@ export let sort = (comp, array) => {
|
|
|
917
917
|
}
|
|
918
918
|
|
|
919
919
|
/**
|
|
920
|
-
* Rotates
|
|
920
|
+
* Rotates array elements by the specified amount to the right, in place.
|
|
921
921
|
*
|
|
922
|
-
* If
|
|
923
|
-
* to the left. See examples.
|
|
922
|
+
* If value is negative, array elements will be rotated by the
|
|
923
|
+
* specified amount to the left. See examples.
|
|
924
924
|
*
|
|
925
925
|
* @param n: The number of elements to rotate by
|
|
926
926
|
* @param arr: The array to be rotated
|
package/array.md
CHANGED
|
@@ -36,7 +36,7 @@ No other changes yet.
|
|
|
36
36
|
length : Array<a> -> Number
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
Provides the length of the input array.
|
|
40
40
|
|
|
41
41
|
Parameters:
|
|
42
42
|
|
|
@@ -114,7 +114,7 @@ Returns:
|
|
|
114
114
|
Examples:
|
|
115
115
|
|
|
116
116
|
```grain
|
|
117
|
-
Array.init(5, n => n + 3) // [>
|
|
117
|
+
Array.init(5, n => n + 3) // [> 3, 4, 5, 6, 7]
|
|
118
118
|
```
|
|
119
119
|
|
|
120
120
|
### Array.**get**
|
|
@@ -195,8 +195,8 @@ No other changes yet.
|
|
|
195
195
|
append : (Array<a>, Array<a>) -> Array<a>
|
|
196
196
|
```
|
|
197
197
|
|
|
198
|
-
Creates a new array with the
|
|
199
|
-
the
|
|
198
|
+
Creates a new array with the elements of the first array followed by
|
|
199
|
+
the elements of the second array. This does not modify the arguments.
|
|
200
200
|
|
|
201
201
|
Parameters:
|
|
202
202
|
|
|
@@ -266,7 +266,7 @@ Returns:
|
|
|
266
266
|
### Array.**cycle**
|
|
267
267
|
|
|
268
268
|
<details disabled>
|
|
269
|
-
<summary tabindex="-1">Added in <code>
|
|
269
|
+
<summary tabindex="-1">Added in <code>0.4.4</code></summary>
|
|
270
270
|
No other changes yet.
|
|
271
271
|
</details>
|
|
272
272
|
|
|
@@ -329,7 +329,7 @@ Parameters:
|
|
|
329
329
|
forEachi : (((a, Number) -> Void), Array<a>) -> Void
|
|
330
330
|
```
|
|
331
331
|
|
|
332
|
-
Iterates an array, calling an iterator function
|
|
332
|
+
Iterates an array, calling an iterator function on each element.
|
|
333
333
|
Also passes the index as the second argument to the function.
|
|
334
334
|
|
|
335
335
|
Parameters:
|
|
@@ -527,7 +527,7 @@ Returns:
|
|
|
527
527
|
|
|
528
528
|
|type|description|
|
|
529
529
|
|----|-----------|
|
|
530
|
-
|`Bool`|`true` if all elements satify the condition
|
|
530
|
+
|`Bool`|`true` if all elements satify the condition or `false` otherwise|
|
|
531
531
|
|
|
532
532
|
### Array.**some**
|
|
533
533
|
|
|
@@ -541,7 +541,7 @@ some : ((a -> Bool), Array<a>) -> Bool
|
|
|
541
541
|
```
|
|
542
542
|
|
|
543
543
|
Checks that the given condition is satisfied **at least
|
|
544
|
-
once** by an
|
|
544
|
+
once** by an element in the input array.
|
|
545
545
|
|
|
546
546
|
Parameters:
|
|
547
547
|
|
|
@@ -554,7 +554,7 @@ Returns:
|
|
|
554
554
|
|
|
555
555
|
|type|description|
|
|
556
556
|
|----|-----------|
|
|
557
|
-
|`Bool`|`true` if one or more elements satify the condition
|
|
557
|
+
|`Bool`|`true` if one or more elements satify the condition or `false` otherwise|
|
|
558
558
|
|
|
559
559
|
### Array.**fill**
|
|
560
560
|
|
|
@@ -693,13 +693,13 @@ Parameters:
|
|
|
693
693
|
|param|type|description|
|
|
694
694
|
|-----|----|-----------|
|
|
695
695
|
|`search`|`a`|The value to compare|
|
|
696
|
-
|`array`|`Array<a>`|The array to
|
|
696
|
+
|`array`|`Array<a>`|The array to inspect|
|
|
697
697
|
|
|
698
698
|
Returns:
|
|
699
699
|
|
|
700
700
|
|type|description|
|
|
701
701
|
|----|-----------|
|
|
702
|
-
|`Bool`|`true` if the value exists in the array
|
|
702
|
+
|`Bool`|`true` if the value exists in the array or `false` otherwise|
|
|
703
703
|
|
|
704
704
|
### Array.**find**
|
|
705
705
|
|
|
@@ -725,7 +725,7 @@ Returns:
|
|
|
725
725
|
|
|
726
726
|
|type|description|
|
|
727
727
|
|----|-----------|
|
|
728
|
-
|`Option<a>`|`Some(element)` containing the first value found
|
|
728
|
+
|`Option<a>`|`Some(element)` containing the first value found or `None` otherwise|
|
|
729
729
|
|
|
730
730
|
### Array.**findIndex**
|
|
731
731
|
|
|
@@ -751,7 +751,7 @@ Returns:
|
|
|
751
751
|
|
|
752
752
|
|type|description|
|
|
753
753
|
|----|-----------|
|
|
754
|
-
|`Option<Number>`|`Some(index)` containing the index of the first element found
|
|
754
|
+
|`Option<Number>`|`Some(index)` containing the index of the first element found or `None` otherwise|
|
|
755
755
|
|
|
756
756
|
### Array.**product**
|
|
757
757
|
|
|
@@ -1030,7 +1030,7 @@ Returns:
|
|
|
1030
1030
|
### Array.**sort**
|
|
1031
1031
|
|
|
1032
1032
|
<details disabled>
|
|
1033
|
-
<summary tabindex="-1">Added in <code>
|
|
1033
|
+
<summary tabindex="-1">Added in <code>0.4.5</code></summary>
|
|
1034
1034
|
No other changes yet.
|
|
1035
1035
|
</details>
|
|
1036
1036
|
|
|
@@ -1052,7 +1052,7 @@ Parameters:
|
|
|
1052
1052
|
### Array.**rotate**
|
|
1053
1053
|
|
|
1054
1054
|
<details disabled>
|
|
1055
|
-
<summary tabindex="-1">Added in <code>
|
|
1055
|
+
<summary tabindex="-1">Added in <code>0.4.5</code></summary>
|
|
1056
1056
|
No other changes yet.
|
|
1057
1057
|
</details>
|
|
1058
1058
|
|
|
@@ -1060,10 +1060,10 @@ No other changes yet.
|
|
|
1060
1060
|
rotate : (Number, Array<a>) -> Void
|
|
1061
1061
|
```
|
|
1062
1062
|
|
|
1063
|
-
Rotates
|
|
1063
|
+
Rotates array elements by the specified amount to the right, in place.
|
|
1064
1064
|
|
|
1065
|
-
If
|
|
1066
|
-
to the left. See examples.
|
|
1065
|
+
If value is negative, array elements will be rotated by the
|
|
1066
|
+
specified amount to the left. See examples.
|
|
1067
1067
|
|
|
1068
1068
|
Parameters:
|
|
1069
1069
|
|