mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 17:41:41 +00:00
Haskell: Fix !! operator
- Use a finite list, as infinite lists are not introduced yet - Use a list starting from 1 instead of 0, to make it obvious that the element returned comes from the list (and is not the second argument to !!).
This commit is contained in:
parent
edfc99e198
commit
b5cb14703a
@ -81,7 +81,7 @@ not False -- True
|
||||
[5,4..1] -- [5, 4, 3, 2, 1]
|
||||
|
||||
-- indexing into a list
|
||||
[0..] !! 5 -- 5
|
||||
[1..10] !! 3 -- 4
|
||||
|
||||
-- You can also have infinite lists in Haskell!
|
||||
[1..] -- a list of all the natural numbers
|
||||
|
Loading…
Reference in New Issue
Block a user