Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org
You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Beginners digest..." Today's Topics: 1. Re: Issue installing reactive-banana-5.0.0.1 (Heinrich Apfelmus) ---------------------------------------------------------------------- Message: 1 Date: Sat, 05 May 2012 09:40:46 +0200 From: Heinrich Apfelmus <apfel...@quantentunnel.de> Subject: Re: [Haskell-beginners] Issue installing reactive-banana-5.0.0.1 To: beginners@haskell.org Message-ID: <jo2lhu$vqb$1...@dough.gmane.org> Content-Type: text/plain; charset=UTF-8; format=flowed Miguel Negrao wrote: > > One other question, is it possible in reactive-banana to define > ?recursive? event streams. For instance consider a stream which > receives numbers between 0.0 and 1.0. If the last outputted value > was between 0.8 an 1.0 then output 1-x otherwise output x. After that > it only leta numbers through if they are between 0.0 and 0.2 or > between 0.8 and 1.0. The standard way to do recursion in reactive-banana is to use multiple recursion between a Behavior and an Event . See also http://stackoverflow.com/a/7852344/403805 Note that the specification you gave does not require recursion, though. Here an implementation of your example. import Reactive.Banana example :: Event t Double -> Event t Double example e = filterJust e2 where e2 = f <$> bIsFirst <@> e bIsFirst = stepper True $ False <$ e between x a b = a < x && x < b f True x | between x 0.8 1.0 = Just $ 1 - x | otherwise = Just $ x f False x | between x 0.8 1.0 = Just $ x | between x 0.0 0.2 = Just $ x | otherwise = Nothing Here an example output GHCi> interpretModel example [[0.9],[0.3],[0.4]] [[9.999999999999998e-2],[],[]] Best regards, Heinrich Apfelmus -- http://apfelmus.nfshost.com ------------------------------ _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 47, Issue 6 ****************************************