Concurrency in functional code will be to use the op state. in crease
import Data.List counter :: (Int, Int) -> Bool -> (Int, Int) counter (_, previous_next) reset = let output = if reset then 0 else previous_next next = output +1 in (output, next) runCounter :: [Bool] -> (Int, Int) runCounter = foldl' counter (0,1) main = do let resets = [True, False, True, False, False] result = fst $ runCounter resets print result
source share