Reputation: 259
It is clear. I had following error. How can I remove it. I need to process all of the list.
uncaught exception Subscript [subscript out of bounds]
raised at: Basis/Implementation/list.sml:...
It's in SML/NJ and I am working with lists.
Thank You.
Upvotes: 1
Views: 3692
Reputation: 50858
The error means you're trying to access an element with an index that isn't in the list.
For instance:
- List.nth([0,1,2], 7);
uncaught exception Subscript [subscript out of bounds]
raised at: Basis/Implementation/list.sml:47.35-47.44
You solve this problem by not trying to access nonexistent elements. You should generally be careful with dealing with functions like List.nth
, List.take
, List.drop
, ..., as they're partial functions, which only work for certain inputs.
Upvotes: 5