From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.3 required=5.0 tests=AWL,SPF_SOFTFAIL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 9F1CFBC6B for ; Wed, 10 Oct 2007 12:09:56 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAF5BDEfAI/YBnWdsb2JhbACBWoxuAgEBCw8I X-IronPort-AV: E=Sophos;i="4.21,253,1188770400"; d="scan'208";a="2815006" Received: from ns.inescn.pt (HELO animal.inescn.pt) ([192.35.246.1]) by mail2-smtp-roc.national.inria.fr with ESMTP; 10 Oct 2007 12:09:56 +0200 Received: from localhost (localhost [127.0.0.1]) by animal.inescn.pt (8.13.8/8.13.6/9) with ESMTP id l9AA9bZs023281; Wed, 10 Oct 2007 11:09:37 +0100 (WEST) X-Virus-Scanned: amavisd-new at inescporto.pt Received: from animal.inescn.pt ([127.0.0.1]) by localhost (animal.inescn.pt [127.0.0.1]) (amavisd-new, port 10024) with LMTP id eL2M-g66CYkM; Wed, 10 Oct 2007 11:09:12 +0100 (WEST) Received: from [194.117.30.94] (morfina.inescn.pt [194.117.30.94]) by animal.inescn.pt (8.13.8/8.13.8/26) with ESMTP id l9AA8FXr023056; Wed, 10 Oct 2007 11:08:15 +0100 (WEST) Message-ID: <470CA488.1070804@inescporto.pt> Date: Wed, 10 Oct 2007 11:08:08 +0100 From: Hugo Ferreira User-Agent: Thunderbird 2.0.0.6 (X11/20070806) MIME-Version: 1.0 To: skaller Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Functional design for a basic simulation pipe. References: <470C8199.4080708@inescporto.pt> <1192005274.6285.4.camel@rosella.wigram> In-Reply-To: <1192005274.6285.4.camel@rosella.wigram> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; 0100,:01 val:01 val:01 wrote:01 wrote:01 rec:01 caml-list:01 termination:01 data:02 data:02 exp:02 exp:02 match:02 functional:02 functional:02 Hello, skaller wrote: > On Wed, 2007-10-10 at 08:39 +0100, Hugo Ferreira wrote: > >> # let exp = gen_events |> gen_states |> analyze_data |> check_stop ;; >> val exp : '_a -> unit = >> >> And execute it so: >> >> # let start_state = () ;; >> val start_state : unit = () >> >> # let _ = exp start_state ;; >> - : unit = () > >> My question is: how can one design and implement such a "pull pipe" and >> solve the problem I have of propagating state back to a previous >> function. > 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 Regards, Hugo F. > Assume > > f : state_t -> state_t option > > is your state transformer, then > > let rec go state = > match f state with > | Some state -> go state > | None -> () > > will do it. >