Skip to content

Commit dc84db9

Browse files
committed
1 parent 12e10f3 commit dc84db9

File tree

7 files changed

+22
-4
lines changed

7 files changed

+22
-4
lines changed

Diff for: jscomp/others/belt_List.ml

+5
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,11 @@ let toArray ( x : _ t) =
407407
fillAux arr 0 x;
408408
arr
409409

410+
let shuffle xs =
411+
let v = toArray xs in
412+
A.shuffleInPlace v ;
413+
ofArray v
414+
410415
let rec fillAuxMap arr i x f =
411416
match x with
412417
| [] -> ()

Diff for: jscomp/others/belt_List.mli

+6
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,12 @@ val makeBy: int -> (int -> 'a) -> 'a t
126126
]}
127127
*)
128128

129+
val shuffle: 'a t -> 'a t
130+
(** [shuffle xs]
131+
@return a new list in random order
132+
*)
133+
134+
129135
val drop: 'a t -> int -> 'a t option
130136
(** [drop xs n]
131137

Diff for: jscomp/xwatcher/xwatcher.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
'use strict';
1+
22

33
import * as Path from "path";
44
import * as Js_option from "../../lib/es6/js_option.js";

Diff for: jscomp/xwatcher/xwatcher_current.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
'use strict';
1+
22

33
import * as Fs from "fs";
44
import * as Path from "path";

Diff for: jscomp/xwatcher/xwatcher_util.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
'use strict';
1+
22

33
import * as Fs from "fs";
44
import * as Path from "path";

Diff for: lib/es6/js_typed_array.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
'use strict';
1+
22

33

44
var ArrayBuffer = /* module */[];

Diff for: lib/js/belt_List.js

+7
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,12 @@ function toArray(x) {
692692
return arr;
693693
}
694694

695+
function shuffle(xs) {
696+
var v = toArray(xs);
697+
Belt_Array.shuffleInPlace(v);
698+
return ofArray(v);
699+
}
700+
695701
function reverseConcat(_l1, _l2) {
696702
while(true) {
697703
var l2 = _l2;
@@ -1463,6 +1469,7 @@ exports.getExn = getExn;
14631469
exports.make = make;
14641470
exports.makeByU = makeByU;
14651471
exports.makeBy = makeBy;
1472+
exports.shuffle = shuffle;
14661473
exports.drop = drop;
14671474
exports.take = take;
14681475
exports.splitAt = splitAt;

0 commit comments

Comments
 (0)