[Haskell-beginners] Issue installing reactive-banana-5.0.0.1

Miguel Negrao miguel.negrao-lists at friendlyvirus.org
Sun May 6 21:35:19 CEST 2012


A 06/05/2012, às 14:31, Heinrich Apfelmus escreveu:
> Ah, ok, then I don't understand your specification.
> 
> Could you give a specification in terms of a simple list transformation
> 
>  example :: [Double] -> [Double]
> 
> ? All list functions are allowed, we can then transform it into a style that uses only the combinators available in reactive-banana.

Ok, this should demonstrate an example of what I mean:

module Main where

main :: IO()
main = print $ test [0.9,0.1,0.2,0.8]
--should output [0.9,0.1,0.8,0.8]

test :: [Double]->[Double]
test (x:xs) = x : test1 xs x
test [] = []

test1:: [Double]->Double->[Double]
test1 (x:xs) lastValue = let
	y = if lastValue>=0.8 then x else 1.0-x
	in if (y<=0.2) || (y>=0.8) then y : test1 xs y else test1 xs lastValue
test1 [] _ = []   

best,
Miguel Negrão


More information about the Beginners mailing list