Skip to content

Commit dd45bda

Browse files
2 parents 79f6f50 + 211e7e3 commit dd45bda

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/prelude.cog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ Def Index (
215215
Let N be Integer!;
216216
Let L be List!;
217217

218+
When < 0 N ( Error Join "Invalid index " Show N );
219+
218220
Do If Zero? N ( return First element of L )
219221
else (
220222
When Empty? L ( Error "Index is beyond end of list" );

0 commit comments

Comments
 (0)