
27 Jan
2017
27 Jan
'17
1:32 a.m.
Hello cafe, I was reading Stephen's Arrow Tutorial [1], where (among other things), a way to compute the running mean of a stream of integers using circular programming (ArrowLoop) is shown: mean5 :: Fractional a => Circuit a a mean5 = proc value -> do rec (lastTot, lastN) <- delay (0,0) -< (tot, n) let (tot, n) = (lastTot + value, lastN + 1) let mean = tot / n returnA -< mean To understand the example better I tried to convert the `rec do` notation to plain loop/(>>>) one (i.e. without syntactic sugar), but failed. So I ask: what's the sour version of `mean5`? -F [1] https://en.wikibooks.org/wiki/Haskell/Arrow_tutorial