From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 46A95BBA7 for ; Sun, 5 Feb 2006 19:07:59 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k15I7wlR014404 for ; Sun, 5 Feb 2006 19:07:58 +0100 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id TAA15247 for ; Sun, 5 Feb 2006 19:07:58 +0100 (MET) Received: from einhorn.in-berlin.de (einhorn.in-berlin.de [192.109.42.8]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k15I7viY014397 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Sun, 5 Feb 2006 19:07:58 +0100 X-Envelope-From: oliver@first.in-berlin.de X-Envelope-To: Received: from first.in-berlin.de (e178049075.adsl.alicedsl.de [85.178.49.75]) (authenticated bits=0) by einhorn.in-berlin.de (8.12.10/8.12.10/Debian-4) with ESMTP id k15I7uI0006927 for ; Sun, 5 Feb 2006 19:07:56 +0100 Received: by first.in-berlin.de (Postfix, from userid 501) id 126492102AD; Sun, 5 Feb 2006 19:07:13 +0100 (CET) Date: Sun, 5 Feb 2006 19:07:13 +0100 From: Oliver Bandel To: caml-list@inria.fr Subject: Re: [Caml-list] From a recursive circuit to a functional/recursive OCaml-code... Message-ID: <20060205180713.GA2068@first.in-berlin.de> References: <20060204211943.GA590@first.in-berlin.de> <1139106546.8453.87.camel@rosella> <20060205041600.GA5936@first.in-berlin.de> <1139118167.8453.254.camel@rosella> <20060205141726.GA491@first.in-berlin.de> <1139155545.3075.51.camel@rosella> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1139155545.3075.51.camel@rosella> User-Agent: Mutt/1.5.6i X-Scanned-By: MIMEDefang_at_IN-Berlin_e.V. on 192.109.42.8 X-Miltered: at concorde with ID 43E63EFE.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 43E63EFD.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; oliver:01 bandel:01 oliver:01 in-berlin:01 caml-list:01 recursive:01 recursive:01 ocaml-code:01 bandel:01 wrote:01 wrote:01 functional:02 functional:02 output:02 types:02 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=disabled version=3.0.3 On Mon, Feb 06, 2006 at 03:05:45AM +1100, skaller wrote: > On Sun, 2006-02-05 at 15:17 +0100, Oliver Bandel wrote: > > Looking at > > http://www.belug.org/~ob/struktur-grafisch.jpg > > the bottom diagram, I would do this: > > type state = { e:t; u:t } > > for some type t I don't know about, possibly the types > are different, but this will do for exposition. > > You also have arrows > > a: t * t -> t > b: t * t -> t > c: t -> t [...] Ah, OK, that's fine to start with the type! :) Starting the task with the type clarifies a lot! :) > > So the clock function is simply > > let step (s:state) x = > { s with > e = c s.u; > u = b (x, s.e) > } > in s, a (x, s.e) OK, that's nice... I had forgotten how (but knew that I once knew that it must be possible) to make a functional record-update-copy. The "with" keyword is a fine thing. :) Looks so much smaller the code, much nicer than the let...in stuff :) > > This function accepts the state and a new input x, > and returns the state and the output y. OK, I will explore it. Thanks. Ciao, Oliver