Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
- Fix `-nostdlib` internal compiler option. https://github.com/rescript-lang/rescript-compiler/pull/6824
- Remove a number of ast nodes never populated by the .res parser, and resulting dead code. https://github.com/rescript-lang/rescript-compiler/pull/6830
- Remove coercion with 2 types from internal representation. Coercion `e : t1 :> t2` was only supported in `.ml` syntax and never by the `.res` parser. https://github.com/rescript-lang/rescript-compiler/pull/6829
- Convert `caml_format` and `js_math` to `.res`. https://github.com/rescript-lang/rescript-compiler/pull/6834

#### :nail_care: Polish

Expand Down
8 changes: 7 additions & 1 deletion jscomp/others/belt_Array.res
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,16 @@ let swapUnsafe = (xs, i, j) => {
setUnsafe(xs, j, tmp)
}


@val @scope("Math") external random : unit => float = "random"
@val @scope("Math") external floor : float => int = "floor"
external toFloat: int => float = "%floatofint"

let shuffleInPlace = xs => {
let len = length(xs)
let random_int = (min, max) => floor(random() *. toFloat(max - min)) + min
for i in 0 to len - 1 {
swapUnsafe(xs, i, Js_math.random_int(i, len)) /* [i,len) */
swapUnsafe(xs, i, random_int(i, len)) /* [i,len) */
}
}

Expand Down
Loading