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 8A6F9BB81 for ; Sat, 4 Feb 2006 22:20:33 +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 k14LKXrD007584 for ; Sat, 4 Feb 2006 22:20:33 +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 WAA02771 for ; Sat, 4 Feb 2006 22:20:32 +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 k14LKVM5020886 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Sat, 4 Feb 2006 22:20:32 +0100 X-Envelope-From: oliver@first.in-berlin.de X-Envelope-To: Received: from first.in-berlin.de (e178045209.adsl.alicedsl.de [85.178.45.209]) (authenticated bits=0) by einhorn.in-berlin.de (8.12.10/8.12.10/Debian-4) with ESMTP id k14LKUYg028648 for ; Sat, 4 Feb 2006 22:20:31 +0100 Received: by first.in-berlin.de (Postfix, from userid 501) id 9ABEB20D756; Sat, 4 Feb 2006 22:19:43 +0100 (CET) Date: Sat, 4 Feb 2006 22:19:43 +0100 From: Oliver Bandel To: caml-list@inria.fr Subject: From a recursive circuit to a functional/recursive OCaml-code... Message-ID: <20060204211943.GA590@first.in-berlin.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 43E51AA1.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 43E51A9F.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 recursive:01 recursive:01 ocaml-code:01 non-trivial:01 foerster:01 ocaml:01 ocaml:01 stdin:01 recursion:01 mailinglist:98 functions: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 Hello, how to implement a simple non-trivial machine (Heinz von Foerster) in a purely functional manner? With functional/recursive OCaml code? I had written a mail with attachement (which contains a jpeg with the structure of the circuit), but it seems it was blocked or filtered away by the OCaml mailinglist software?! So I try to give it as some formulas: let u = func_B x e let e = func_C u let y = func_A x I want to have y as a function of x (and x is read from stdin as int). With each next input of x the next y should be calculated and printed (maybe u and e also printing). Normally - in the non-functional world - I would use variables with a start-value and then iterate with each input. So I had to save some values for some calculations (call by value), so that I do not change the values. The functional way should make it unnecessary to save the values. The functional programming paradigm should help here. But it's a recursive process... or should I use iterations, even if I use a functional language here? Or, when using recursion, do i have to use mutual recursive functions or recursive values here?! Any hint is welcome. TIA, Oliver