Skip to content

Commit 743b236

Browse files
authored
Cleanup: convert caml_format and js_math to .res. (#6834)
* Cleanup: convert caml_format to .res. * Also convert `js_math` to `.res`. * Update caml_format.res * Update release.ninja * Remove dependency on js_math. * Artifacts.
1 parent 83ef108 commit 743b236

15 files changed

+1129
-1016
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
- Fix `-nostdlib` internal compiler option. https://github.com/rescript-lang/rescript-compiler/pull/6824
4444
- 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
4545
- 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
46+
- Convert `caml_format` and `js_math` to `.res`. https://github.com/rescript-lang/rescript-compiler/pull/6834
4647

4748
#### :nail_care: Polish
4849

jscomp/others/belt_Array.res

+7-1
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,16 @@ let swapUnsafe = (xs, i, j) => {
6464
setUnsafe(xs, j, tmp)
6565
}
6666

67+
68+
@val @scope("Math") external random : unit => float = "random"
69+
@val @scope("Math") external floor : float => int = "floor"
70+
external toFloat: int => float = "%floatofint"
71+
6772
let shuffleInPlace = xs => {
6873
let len = length(xs)
74+
let random_int = (min, max) => floor(random() *. toFloat(max - min)) + min
6975
for i in 0 to len - 1 {
70-
swapUnsafe(xs, i, Js_math.random_int(i, len)) /* [i,len) */
76+
swapUnsafe(xs, i, random_int(i, len)) /* [i,len) */
7177
}
7278
}
7379

0 commit comments

Comments
 (0)