Skip to content

Commit 425a8fa

Browse files
committed
Unpack the parameter of Vector.tabulate/Array.tabulate
1 parent d4ae084 commit 425a8fa

File tree

10 files changed

+11
-15
lines changed

10 files changed

+11
-15
lines changed

lib/lunarml/ml/basis/js/array-prim.sml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ fun update (arr, i, value) = if i < 0 orelse length arr <= i then
1111
Unsafe.Array.update (arr, i, value)
1212
fun array (n, init) = _primCall "Array.array" (n, init)
1313
val fromList = _Prim.Array.fromList
14-
val tabulate = _Prim.Array.tabulate
14+
fun tabulate (n, f) = _primCall "call2" (_Prim.Array.tabulate, n, f)
1515
end;
1616
(* equality is defined in equal.sml *)

lib/lunarml/ml/basis/js/vector-prim.sml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ fun sub (vec, i) = if i < 0 orelse length vec <= i then
66
else
77
Unsafe.Vector.sub (vec, i)
88
val fromList = _Prim.Vector.fromList
9-
val tabulate = _Prim.Vector.tabulate
9+
fun tabulate (n, f) = _primCall "call2" (_Prim.Vector.tabulate, n, f)
1010
val concat = _Prim.Vector.concat
1111
end
1212
_equality ''a vector = fn (x, y) => let val n = Vector.length x

lib/lunarml/ml/basis/lua/array-prim.sml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ fun update (arr, i, value) = if i < 0 orelse length arr <= i then
1111
Unsafe.Array.update (arr, i, value)
1212
fun array (n, init) = _primCall "Array.array" (n, init)
1313
val fromList = _Prim.Array.fromList
14-
val tabulate = _Prim.Array.tabulate
14+
fun tabulate (n, f) = _primCall "call2" (_Prim.Array.tabulate, n, f)
1515
end;
1616
(* equality is defined in equal.sml *)

lib/lunarml/ml/basis/lua/vector-prim.sml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ fun sub (vec, i) = if i < 0 orelse length vec <= i then
66
else
77
Unsafe.Vector.sub (vec, i)
88
val fromList = _Prim.Vector.fromList
9-
val tabulate = _Prim.Vector.tabulate
9+
fun tabulate (n, f) = _primCall "call2" (_Prim.Vector.tabulate, n, f)
1010
val concat = _Prim.Vector.concat
1111
end
1212
_equality ''a vector = fn (x, y) => let val n = Vector.length x

lib/lunarml/ml/basis/luajit/array-prim.sml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ fun update (arr, i, value) = if i < 0 orelse length arr <= i then
1111
Unsafe.Array.update (arr, i, value)
1212
fun array (n, init) = _primCall "Array.array" (n, init)
1313
val fromList = _Prim.Array.fromList
14-
val tabulate = _Prim.Array.tabulate
14+
fun tabulate (n, f) = _primCall "call2" (_Prim.Array.tabulate, n, f)
1515
end;
1616
(* equality is defined in equal.sml *)

lib/lunarml/mlinit-continuations.lua

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,7 @@ local function _Vector_unsafeFromListRevN(n, xs)
410410
end
411411
--END
412412
--BEGIN _VectorOrArray_tabulate: _raise _Size
413-
local function _VectorOrArray_tabulate(t)
414-
local n, f = t[1], t[2]
413+
local function _VectorOrArray_tabulate(n, f)
415414
if n < 0 then -- or maxLen < n
416415
_raise(_Size, "(Vector|Array).tabulate")
417416
end

lib/lunarml/mlinit-luajit.lua

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,7 @@ local function _Vector_unsafeFromListRevN(n, xs)
439439
end
440440
--END
441441
--BEGIN _VectorOrArray_tabulate: _raise _Size
442-
local function _VectorOrArray_tabulate(t)
443-
local n, f = t[1], t[2]
442+
local function _VectorOrArray_tabulate(n, f)
444443
if n < 0 then -- or maxLen < n
445444
_raise(_Size, "(Vector|Array).tabulate")
446445
end

lib/lunarml/mlinit.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,8 +467,7 @@ function _Vector_unsafeFromListRevN(n, xs) {
467467
}
468468
//END
469469
//BEGIN _VectorOrArray_tabulate: _Size
470-
function _VectorOrArray_tabulate(t) {
471-
const n = t[0], f = t[1];
470+
function _VectorOrArray_tabulate(n, f) {
472471
if (n < 0 || n > 0xffffffff) {
473472
throw _Size;
474473
}

lib/lunarml/mlinit.lua

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,7 @@ local function _Vector_unsafeFromListRevN(n, xs)
411411
end
412412
--END
413413
--BEGIN _VectorOrArray_tabulate: _raise _Size
414-
local function _VectorOrArray_tabulate(t)
415-
local n, f = t[1], t[2]
414+
local function _VectorOrArray_tabulate(n, f)
416415
if n < 0 then -- or maxLen < n
417416
_raise(_Size, "(Vector|Array).tabulate")
418417
end

src/initialenv.sml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ struct
527527
, VId_Vector_tabulate
528528
, TypeScheme
529529
( [(tyVarA, NONE)]
530-
, PT.pair (PT.int, PT.int --> tyA) --> PT.vector tyA
530+
, PT.function2 (PT.int, PT.int --> tyA) (PT.vector tyA)
531531
)
532532
)
533533
, ( "_Prim.Vector.concat"
@@ -543,7 +543,7 @@ struct
543543
, VId_Array_tabulate
544544
, TypeScheme
545545
( [(tyVarA, NONE)]
546-
, PT.pair (PT.int, PT.int --> tyA) --> PT.array tyA
546+
, PT.function2 (PT.int, PT.int --> tyA) (PT.array tyA)
547547
)
548548
)
549549
, ("_Prim.Lua.NIL", VId_Lua_NIL, TypeScheme ([], PT.lua_value))

0 commit comments

Comments
 (0)