Version française
Home     About     Download     Resources     Contact us    
Browse thread
Functional design for a basic simulation pipe.
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Vincent Aravantinos <vincent.aravantinos@y...>
Subject: Re: [Caml-list] Functional design for a basic simulation pipe.

Le 10 oct. 07 à 12:08, Hugo Ferreira a écrit :

> Apologies for being so obtuse but I cannot to see how this solves my
> problem. Please note that I am not well versed in functional  
> programming
> so that what I am asking may not be possible. Lets say I have a small
> pipe of 3 actions:
>
> let exp = a |> b |> c
>
> a: requires the input of a state and outputs an event
> b: requires input of a state and the event generated at that state and
> outputs processed data
> c: consumes n number elements of processed data and stops when it
> requires no more such data
>
> Note that "c" will "pull in" for example 10 states and check for
> termination, "b" will therefore need "pull in" 10 events. Each time it
> pulls in an event it generates a state. This last state must be made
> available to "a" so that it may generate its next event.
>
> The issue here is how can I implement this so that I can flexibly
> configure experiments by "constructing" a chain of actions but  
> still be
> able to pass back the state to one of those actions. Something like:
>
> let exp = a |> b (output 1 back to a) |> c

Just to be sure I understood well, here is a diagram:

--> a --> b -+-------------------------------------------------> output1
              |
              +--state1-> a --> b -+---------------------------->  
output2
                                   |
                                   +-state2-> a --> b -+-------->  
output3
                                                       |
                                                          ...
                                                               ->  
outputn

                                                                     |
                                                                     |
                                                                     |
                                                                     V

                                                                     c


Do you agree with this ? (n beeing a variable of course...)
Shall c also take the states ?

(I believe in good drawings to help finding an answer...)