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
When there's a function that takes a list/array/string and an index, and the index is outside the bounds of the list, some functions will raise, some wrap, some do the thing at the start/end based on where the index is, and some do the same thing regardless of whether its out-of-bounds.
They should all behave the same on all platforms. What should that behaviour be?
My preference would be, in order:
normalize to valid bound
normalize with wrapping
raise an error if out of bounds
use option/result
silently return the input for out of bounds
By normalize-to-valid-bound I mean:
let index =
if index < 0
then 0
else min (length, index)
By normalize-with-wrapping I mean:
let index =
if index < 0
then max (length + index), 0
else min (length, index)
The text was updated successfully, but these errors were encountered:
When there's a function that takes a list/array/string and an index, and the index is outside the bounds of the list, some functions will raise, some wrap, some do the thing at the start/end based on where the index is, and some do the same thing regardless of whether its out-of-bounds.
They should all behave the same on all platforms. What should that behaviour be?
My preference would be, in order:
By normalize-to-valid-bound I mean:
By normalize-with-wrapping I mean:
The text was updated successfully, but these errors were encountered: