Added a mention of filter

This commit is contained in:
Evan Hock 2024-12-08 23:14:54 -08:00
parent ed6c2afda2
commit 0d10b10425

View File

@ -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