|
3 | 3 | Has constant time (O(1)) [get](#get), [set](#set) and [length](#length) operations. |
4 | 4 |
|
5 | 5 | Arrays have a fixed length, if you want to be able to add an arbitrary number of elements maybe you want a [List](List.mdx#)}. |
| 6 | + You can create an `array` in Rescript with the `[1, 2, 3]` syntax. |
6 | 7 | */ |
7 | 8 | type t<'a> = array<'a> |
8 | 9 |
|
9 | | -/** # Create |
10 | | -
|
11 | | - You can create an `array` in Rescript with the `[1, 2, 3]` syntax. |
12 | | -*/ |
13 | 10 | /** Create an array with only one element. |
14 | 11 |
|
15 | 12 | ## Examples |
@@ -92,7 +89,6 @@ let fromList: list<'a> => t<'a> |
92 | 89 | */ |
93 | 90 | let clone: t<'a> => t<'a> |
94 | 91 |
|
95 | | -/** # Basic operations */ |
96 | 92 | /** Get the element at the specified index. |
97 | 93 |
|
98 | 94 | The first element has index number 0. |
@@ -124,7 +120,7 @@ let get: (t<'a>, int) => 'a |
124 | 120 |
|
125 | 121 | /** Returns, as an [Option](Option.mdx#), the element at index number `n` of array `a`. |
126 | 122 |
|
127 | | - Returns `None` if `n` is outside the range `0` to [(Array.length(a) - 1)]. |
| 123 | + Returns `None` if `n` is outside the range `0` to `Array.length(a) - 1`. |
128 | 124 |
|
129 | 125 | ## Examples |
130 | 126 |
|
@@ -251,7 +247,6 @@ let reverse: t<'a> => unit |
251 | 247 | */ |
252 | 248 | let sort: (t<'a>, ~compare: ('a, 'a) => int) => unit |
253 | 249 |
|
254 | | -/** # Query */ |
255 | 250 | /** Check if an array is empty. |
256 | 251 |
|
257 | 252 | ## Examples |
@@ -336,7 +331,7 @@ let find: (t<'a>, ~f: 'a => bool) => option<'a> |
336 | 331 | */ |
337 | 332 | let findIndex: (t<'a>, ~f: (int, 'a) => bool) => option<(int, 'a)> |
338 | 333 |
|
339 | | -/** Test if an array contains the specified element using the provided [equal] to test for equality. |
| 334 | +/** Test if an array contains the specified element using the provided `equal` to test for equality. |
340 | 335 |
|
341 | 336 | ## Examples |
342 | 337 |
|
@@ -408,7 +403,6 @@ let extent: (t<'a>, ~compare: ('a, 'a) => int) => option<('a, 'a)> |
408 | 403 | */ |
409 | 404 | let sum: (t<'a>, module(TableclothContainer.Sum with type t = 'a)) => 'a |
410 | 405 |
|
411 | | -/** # Transform */ |
412 | 406 | /** Create a new array which is the result of applying a function `f` to every element. |
413 | 407 |
|
414 | 408 | ## Examples |
@@ -560,7 +554,7 @@ let flatten: t<t<'a>> => t<'a> |
560 | 554 |
|
561 | 555 | If one array is longer, the extra elements are dropped. |
562 | 556 |
|
563 | | - The same as [Array.map2(~f=Tuple2.make)] |
| 557 | + The same as `Array.map2(~f=Tuple2.make)` |
564 | 558 |
|
565 | 559 | ## Examples |
566 | 560 |
|
@@ -605,7 +599,6 @@ let map2: (t<'a>, t<'b>, ~f: ('a, 'b) => 'c) => t<'c> |
605 | 599 | */ |
606 | 600 | let map3: (t<'a>, t<'b>, t<'c>, ~f: ('a, 'b, 'c) => 'd) => t<'d> |
607 | 601 |
|
608 | | -/** # Deconstruct */ |
609 | 602 | /** Split an array into a [Tuple2](Tuple2.mdx#) of arrays. Values which `f` returns true for will end up in [Tuple2.first](Tuple2.mdx#first). |
610 | 603 |
|
611 | 604 | ## Examples |
@@ -664,7 +657,6 @@ let splitWhen: (t<'a>, ~f: 'a => bool) => (t<'a>, t<'a>) |
664 | 657 | */ |
665 | 658 | let unzip: t<('a, 'b)> => (t<'a>, t<'b>) |
666 | 659 |
|
667 | | -/** # Iterate */ |
668 | 660 | /** Iterates over the elements of invokes `f` for each element. |
669 | 661 |
|
670 | 662 | ## Examples |
@@ -749,7 +741,6 @@ let chunksOf: (t<'a>, ~size: int) => t<t<'a>> |
749 | 741 | */ |
750 | 742 | let sliding: (~step: int=?, t<'a>, ~size: int) => t<t<'a>> |
751 | 743 |
|
752 | | -/** # Convert */ |
753 | 744 | /** Converts an array of strings into a [String](String.mdx#), placing `sep` between each string in the result. |
754 | 745 |
|
755 | 746 | ## Examples |
@@ -803,7 +794,15 @@ let toList: t<'a> => list<'a> |
803 | 794 | */ |
804 | 795 | let toIndexedList: t<'a> => list<(int, 'a)> |
805 | 796 |
|
806 | | -/** Test two arrays for equality using the provided function to test pairs of elements. */ |
| 797 | +/** Test two arrays for equality using the provided function to test pairs of elements. |
| 798 | +
|
| 799 | + ## Examples |
| 800 | +
|
| 801 | + ```rescript |
| 802 | + Array.equal(["cat", "dog"], ["cat", "dog"], String.equal) === true |
| 803 | + Array.equal(["cat", "dog"], ["parrot", "dog"], String.equal) === false |
| 804 | + ``` |
| 805 | +*/ |
807 | 806 | let equal: (t<'a>, t<'a>, ('a, 'a) => bool) => bool |
808 | 807 |
|
809 | 808 | /** Compare two arrays using the provided `f` function to compare pairs of elements. |
|
0 commit comments