From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 82523BB81 for ; Sun, 5 Feb 2006 05:16:45 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k154Gj5x003515 for ; Sun, 5 Feb 2006 05:16:45 +0100 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id FAA06483 for ; Sun, 5 Feb 2006 05:16:44 +0100 (MET) Received: from einhorn.in-berlin.de (einhorn.in-berlin.de [192.109.42.8]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k154Ghur003512 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Sun, 5 Feb 2006 05:16:44 +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 k154GhYg028453 for ; Sun, 5 Feb 2006 05:16:43 +0100 Received: by first.in-berlin.de (Postfix, from userid 501) id 5ADCF20F903; Sun, 5 Feb 2006 05:16:01 +0100 (CET) Date: Sun, 5 Feb 2006 05:16:00 +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: <20060205041600.GA5936@first.in-berlin.de> References: <20060204211943.GA590@first.in-berlin.de> <1139106546.8453.87.camel@rosella> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1139106546.8453.87.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 nez-perce with ID 43E57C2D.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 43E57C2C.000 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 non-trivial:01 foerster:01 recursion:01 ocaml:01 rec:01 terminate:01 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 Sun, Feb 05, 2006 at 01:29:06PM +1100, skaller wrote: > On Sat, 2006-02-04 at 22:19 +0100, Oliver Bandel wrote: > > Hello, > > > > > > how to implement a simple non-trivial machine (Heinz von Foerster) > > in a purely functional manner? > > Define a record S containing your state variables. Is it necessary to have state-variables in a record? Is it then (with records) functional implementation?! > > Write a pure function f: S -> S representing one tick of the > system clock. Hmhhh.... ok, I see. But I'm not clear about how to write this function "f", because it needs mutual recursion... In a purely impeative way I think i woulf find a solution, but thinking about it in Ocaml => blackout. ;-( > > Then write > > let rec run f S = > let S' = f S in > if S' = S then S > else run f S' > in > run f S0 > > Note it may never terminate, it isn't hard to build > an oscillator :) Well, the run-function is not what I was looking for, because the loop is intended to work again and again, so, it is not necessary to have the if-then stuff inside: each clock cycle reads in a new input-value and calculates a new output value and then calls itself again... and inside "f" there also is a feedback. See the second picture in the jpeg-file: http://www.belug.org/~ob/struktur-grafisch.jpg Ciao, Oliver