[Haskell-beginners] FRP and a set of pairwise interacting (colliding) objects
es at ertes.de
Mon Jul 2 10:51:00 CEST 2012
Nathan Hüsken <nathan.huesken at posteo.de> wrote:
> So I would have a main arrow like this (leaving out the Map for which
> I have to lookup the syntax):
> main = proc in -> do
> planet1 <- planets initPlanet1 -< allPlanets
> planet2 <- ...
> allPlanets <- delay  -< [planet1,planet2 ...]
> (I would probably have some arrow managing all planets instead of
> listing them separately)
Yes, that's the basic idea. Just drop in a 'rec' somewhere for the
feedback to work.
> Yes, that makes sense. There is still a little overhead. Assuming
> collisions are symmetric, the OOP approach would only test every pair
> of planets once ... not in the way I wrote it down, but it could
> easily be changed so that it does.
> But here they have to tested twice.
> Thats only factor 2 and probably acceptable. Still, is it avoidable?
Yes, it is. You can write a managing wire transformer (along the lines
of the ones from Control.Wire.Trans.Combine) specifically for colliding
objects. It's really much easier than it sounds. Just have a look into
the source code of that module.
Not to be or to be and (not to be or to be and (not to be or to be and
(not to be or to be and ... that is the list monad.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 836 bytes
Desc: not available
More information about the Beginners