loop package:massiv

Efficient loop with an accumulator
Applicative loop. Use monadic loopM when possible, since it will be more efficient.
Efficient Applicative loop. Result of each iteration is discarded.
loopA_ initial cond incr f === loopA initial cond incr (pure ()) (\i -> id <$ f i)
Similar to loopM, but way less efficient monadic loop with an accumulator that reverses the direction of action application. eg:
>>> loopDeepM 1 (< 20) (+ 2) [] (\i a -> Just (i:a))
Just [1,3,5,7,9,11,13,15,17,19]
Equivalent to:
>>> loopM 19 (>= 1) (subtract 2) [] (\i a -> Just (i:a))
Just [1,3,5,7,9,11,13,15,17,19]
Efficient monadic loop with an accumulator
>>> loopM 1 (< 20) (+ 2) [] (\i a -> Just (i:a))
Just [19,17,15,13,11,9,7,5,3,1]
Deprecated: In favor of loopA_
Similar to loopM_ except the action accepts not only the value for current step, but also for the next one as well.
Similar to loopM_ except the action accepts not only the value for current step, but also for the next one as well.
Efficient monadic loop with extra linear index incremented by 1.
>>> iloopA_ 100 1 (< 10) (+ 2) (\i ix -> print (i, ix))
(100,1)
(101,3)
(102,5)
(103,7)
(104,9)
Efficient monadic loop with an accumulator and extra linear index incremented by 1.
>>> iloopM 100 1 (< 20) (+ 2) [] (\i ix a -> Just ((i, ix) : a))
Just [(109,19),(108,17),(107,15),(106,13),(105,11),(104,9),(103,7),(102,5),(101,3),(100,1)]