mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-04-26 23:23:55 +00:00
Added a mention of filter
This commit is contained in:
parent
ed6c2afda2
commit
0d10b10425
@ -282,6 +282,9 @@ for [0..5] $ \i -> show i
|
||||
-- we could've written that like this too:
|
||||
for [0..5] show
|
||||
|
||||
-- filter keeps only the elements in a list that satisfy a condition
|
||||
filter even [1..10] -- [2, 4, 8, 10]
|
||||
|
||||
-- You can use foldl or foldr to reduce a list
|
||||
-- foldl <fn> <initial value> <list>
|
||||
foldl (\x y -> 2*x + y) 4 [1,2,3] -- 43
|
||||
|
Loading…
Reference in New Issue
Block a user