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 D5B64BB81 for ; Sun, 5 Feb 2006 03:29:21 +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 k152TLWO028523 for ; Sun, 5 Feb 2006 03:29:21 +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 DAA05086 for ; Sun, 5 Feb 2006 03:29:20 +0100 (MET) Received: from smtp3.adl2.internode.on.net (smtp3.adl2.internode.on.net [203.16.214.203]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k152TIw1012200 for ; Sun, 5 Feb 2006 03:29:19 +0100 Received: from rosella (ppp21-250.lns2.syd7.internode.on.net [59.167.21.250]) by smtp3.adl2.internode.on.net (8.13.5/8.13.5) with ESMTP id k152T6iW095804; Sun, 5 Feb 2006 12:59:07 +1030 (CST) (envelope-from skaller@users.sourceforge.net) Subject: Re: [Caml-list] From a recursive circuit to a functional/recursive OCaml-code... From: skaller To: Oliver Bandel Cc: caml-list@inria.fr In-Reply-To: <20060204211943.GA590@first.in-berlin.de> References: <20060204211943.GA590@first.in-berlin.de> Content-Type: text/plain Date: Sun, 05 Feb 2006 13:29:06 +1100 Message-Id: <1139106546.8453.87.camel@rosella> Mime-Version: 1.0 X-Mailer: Evolution 2.4.1 Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 43E56301.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 43E562FE.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 recursive:01 recursive:01 ocaml-code:01 oliver:01 bandel:01 non-trivial:01 foerster:01 rec:01 terminate:01 wrote:01 sourceforge:01 define:01 purely:02 variables: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.0 required=5.0 tests=none autolearn=disabled version=3.0.3 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. Write a pure function f: S -> S representing one tick of the system clock. 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 :) -- John Skaller Felix, successor to C++: http://felix.sf.net