[Haskell-beginners] Issue installing reactive-banana-5.0.0.1
Miguel Negrao
miguel.negrao-lists at friendlyvirus.org
Sun May 6 15:34:41 CEST 2012
A 05/05/2012, às 15:26, Miguel Negrao escreveu:
>
> Hum, that’s not exactly what I wanted. So if it’s the first event just let it through, and then filter it. If it’s not the first event, then do the inversion (1-x) or not depending on the last outputted value, and then filter it.
> An input of
> [[0.9],[0.5],[0.1],[0.9],[0.9]]
> should produce
> [[0.9],[],[0.9],[0.1],[0.9]]
>
> The following code is not correct but it’s closer to what I described:
>
> module Main where
>
> import Reactive.Banana
>
> main :: IO()
> main = do
> list <- interpretModel example [[0.9],[0.3],[0.4],[0.15],[0.87]]
> putStrLn $ show list
>
> example :: Event t Double -> Event t Double
> example e = filterede2
> where
> filterede2 = filterE (\x->between x 0.0 0.2 && between x 0.8 1.0) e2
> e2 = f <$> bIsFirst <@> e <@> e2
>
> bIsFirst = stepper True $ False <$ e
>
> between x a b = a < x && x < b
>
> f True x y = x
> f False x y
> | between y 0.8 1.0 = 1 - x
> | otherwise = x
Actually I just spotted that the filtering should not be done after the “recursive” part. It should be something more like:
> example e = e2 where e2 = filterE (\x->between x 0.0 0.2 && between x 0.8 1.0) (f <$> bIsFirst <@> e <@> e2)
best,
Miguel Negrão
More information about the Beginners
mailing list