You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I get a different output running this code in mlkit v mlton:
letval arr = Array.fromList [1, 2, 3]
val s = ArraySlice.slice (arr, 1, NONE)
in
ArraySlice.foldli (fn (idx, elem, acc) =>
(print (Int.toString idx); acc)
) 0 s
end;
mlton outputs 01
mlkit outputs 12
I believe this is a bug in mlkit, since ArraySlice.foldi doc states that The more general functions foldli and foldri supply f with the index of the corresponding element in the slice.
As I understand it, indices should be relative to the start of the slice, not the array. So index 0 should be the first element of the slice, not the first element of the array.
The text was updated successfully, but these errors were encountered:
Interestingly, also the tests were wrong! It turns out that also MosML outputs 12. I suspect changes were made to the SML Basis Library specification after Peter Sestoft implemented the library functions (and tests) in MosML, which is where the MLKit library function implementations come from. The functions (and tests) have now been changed to match the SML Basis Library specification.
When Peter (@sestoft) implemented the *Slice modules 22 years ago, it was a refactoring of the Array module (and others) and the various old foldli functions and friends gave an index wrt the underlying array.
I get a different output running this code in mlkit v mlton:
mlton outputs
01
mlkit outputs
12
I believe this is a bug in mlkit, since ArraySlice.foldi doc states that
The more general functions foldli and foldri supply f with the index of the corresponding element in the slice.
As I understand it, indices should be relative to the start of the slice, not the array. So index
0
should be the first element of the slice, not the first element of the array.The text was updated successfully, but these errors were encountered: