mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-04-27 07:33:57 +00:00
Removed mentions of arrays to reduce confusion between arrays and lists
This commit is contained in:
parent
c40736ee0f
commit
ed6c2afda2
@ -66,6 +66,7 @@ True || False -- True
|
|||||||
['H', 'e', 'l', 'l', 'o'] -- "Hello"
|
['H', 'e', 'l', 'l', 'o'] -- "Hello"
|
||||||
|
|
||||||
-- Lists can be indexed with the `!!` operator followed by an index
|
-- Lists can be indexed with the `!!` operator followed by an index
|
||||||
|
-- Be aware that since lists are linked lists, this is an O(n) operation
|
||||||
"This is a string" !! 0 -- 'T'
|
"This is a string" !! 0 -- 'T'
|
||||||
|
|
||||||
|
|
||||||
@ -273,7 +274,7 @@ case args of
|
|||||||
map (*2) [1..5] -- [2, 4, 6, 8, 10]
|
map (*2) [1..5] -- [2, 4, 6, 8, 10]
|
||||||
|
|
||||||
-- you can make a for function using map
|
-- you can make a for function using map
|
||||||
for array func = map func array
|
for list func = map func list
|
||||||
|
|
||||||
-- and then use it
|
-- and then use it
|
||||||
for [0..5] $ \i -> show i
|
for [0..5] $ \i -> show i
|
||||||
|
Loading…
Reference in New Issue
Block a user