很明显。我有以下错误。我怎样才能删除它。我需要处理所有列表。
uncaught exception Subscript [subscript out of bounds]
raised at: Basis/Implementation/list.sml:...
Run Code Online (Sandbox Code Playgroud)
它在 SML/NJ 中,我正在处理列表。
谢谢你。
该错误意味着您正在尝试访问索引不在列表中的元素。
例如:
- List.nth([0,1,2], 7);
uncaught exception Subscript [subscript out of bounds]
raised at: Basis/Implementation/list.sml:47.35-47.44
Run Code Online (Sandbox Code Playgroud)
您可以通过不尝试访问不存在的元素来解决此问题。您通常应该小心处理像List.nth, List.take, List.drop, ... 这样的函数,因为它们是偏函数,仅适用于某些输入。