@@ -6,7 +6,7 @@ import Control.Lazy (defer)
6
6
import Data.FoldableWithIndex (foldMapWithIndex , foldlWithIndex , foldrWithIndex )
7
7
import Data.FunctorWithIndex (mapWithIndex )
8
8
import Data.Lazy as Z
9
- import Data.List.Lazy (List , Pattern (..), alterAt , catMaybes , concat , concatMap , cons , delete , deleteAt , deleteBy , drop , dropWhile , elemIndex , elemLastIndex , filter , filterM , findIndex , findLastIndex , foldM , foldMap , foldl , foldr , foldrLazy , fromFoldable , group , groupBy , head , init , insert , insertAt , insertBy , intersect , intersectBy , iterate , last , length , mapMaybe , modifyAt , nil , nub , nubBy , null , partition , range , repeat , replicate , replicateM , reverse , scanrLazy , singleton , slice , snoc , span , stripPrefix , tail , take , takeWhile , transpose , uncons , union , unionBy , unzip , updateAt , zip , zipWith , zipWithA , (!!), (..), (:), (\\))
9
+ import Data.List.Lazy (List , Pattern (..), alterAt , catMaybes , concat , concatMap , cons , delete , deleteAt , deleteBy , drop , dropWhile , elemIndex , elemLastIndex , filter , filterM , findIndex , findLastIndex , foldM , foldMap , foldl , foldr , foldrLazy , fromFoldable , group , groupBy , head , init , insert , insertAt , insertBy , intersect , intersectBy , iterate , last , length , mapMaybe , modifyAt , nil , nub , nubBy , null , partition , range , repeat , replicate , replicateM , reverse , scanlLazy , singleton , slice , snoc , span , stripPrefix , tail , take , takeWhile , transpose , uncons , union , unionBy , unzip , updateAt , zip , zipWith , zipWithA , (!!), (..), (:), (\\))
10
10
import Data.List.Lazy.NonEmpty as NEL
11
11
import Data.Maybe (Maybe (..), isNothing , fromJust )
12
12
import Data.Monoid.Additive (Additive (..))
@@ -394,11 +394,14 @@ testListLazy = do
394
394
infs' = foldrLazy cons nil infs
395
395
in take 1000 infs == take 1000 infs'
396
396
397
- log " scanrLazy should work ok on infinite lists"
397
+ log " scanlLazy should work ok on infinite lists"
398
398
assert let infs = iterate (_ + 1 ) 1
399
- infs' = scanrLazy (\i _ -> i) 0 infs
399
+ infs' = scanlLazy (\_ i -> i) 0 infs
400
400
in take 1000 infs == take 1000 infs'
401
401
402
+ log " scanlLazy folds to the left"
403
+ assert $ scanlLazy (+) 5 (1 ..4 ) == l [6 , 8 , 11 , 15 ]
404
+
402
405
log " can find the first 10 primes using lazy lists"
403
406
let eratos :: List Int -> List Int
404
407
eratos xs = defer \_ ->
0 commit comments