Skip to content

Commit 6560ea7

Browse files
committed
rename toShuffled to shuffle and deprecate it
1 parent f67e8d0 commit 6560ea7

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

lib/es6/List.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ function toArray(x) {
646646
return arr;
647647
}
648648

649-
function toShuffled(xs) {
649+
function shuffle(xs) {
650650
let v = toArray(xs);
651651
$$Array.shuffle(v);
652652
return fromArray(v);
@@ -1298,6 +1298,8 @@ function zip(l1, l2) {
12981298

12991299
let size = length;
13001300

1301+
let toShuffled = shuffle;
1302+
13011303
export {
13021304
length,
13031305
size,
@@ -1310,6 +1312,7 @@ export {
13101312
getExn,
13111313
make,
13121314
fromInitializer,
1315+
shuffle,
13131316
toShuffled,
13141317
drop,
13151318
take,

lib/js/List.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ function toArray(x) {
646646
return arr;
647647
}
648648

649-
function toShuffled(xs) {
649+
function shuffle(xs) {
650650
let v = toArray(xs);
651651
$$Array.shuffle(v);
652652
return fromArray(v);
@@ -1298,6 +1298,8 @@ function zip(l1, l2) {
12981298

12991299
let size = length;
13001300

1301+
let toShuffled = shuffle;
1302+
13011303
exports.length = length;
13021304
exports.size = size;
13031305
exports.head = head;
@@ -1309,6 +1311,7 @@ exports.get = get;
13091311
exports.getExn = getExn;
13101312
exports.make = make;
13111313
exports.fromInitializer = fromInitializer;
1314+
exports.shuffle = shuffle;
13121315
exports.toShuffled = toShuffled;
13131316
exports.drop = drop;
13141317
exports.take = take;

runtime/List.res

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,12 +485,15 @@ let toArray = (x: list<_>) => {
485485
arr
486486
}
487487

488-
let toShuffled = xs => {
488+
let shuffle = xs => {
489489
let v = toArray(xs)
490490
Array.shuffle(v)
491491
fromArray(v)
492492
}
493493

494+
@deprecated("Use `shuffle` instead")
495+
let toShuffled = shuffle
496+
494497
/* let rec fillAuxMap arr i x f =
495498
match x with
496499
| [] -> ()

runtime/List.resi

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,17 @@ List.fromInitializer(~length=5, i => i * i) // list{0, 1, 4, 9, 16}
200200
*/
201201
let fromInitializer: (~length: int, int => 'a) => list<'a>
202202

203+
/**
204+
`shuffle(list)` returns a new list in random order.
205+
206+
## Examples
207+
208+
```rescript
209+
List.shuffle(list{1, 2, 3}) // list{2, 1, 3}
210+
```
211+
*/
212+
let shuffle: list<'a> => list<'a>
213+
203214
/**
204215
`toShuffled(list)` returns a new list in random order.
205216

@@ -209,6 +220,7 @@ let fromInitializer: (~length: int, int => 'a) => list<'a>
209220
List.toShuffled(list{1, 2, 3}) // list{2, 1, 3}
210221
```
211222
*/
223+
@deprecated("Use `shuffle` instead")
212224
let toShuffled: list<'a> => list<'a>
213225

214226
/**

0 commit comments

Comments
 (0)