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 46C93BB81 for ; Sun, 5 Feb 2006 05:04:13 +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 k1544CE5002658 for ; Sun, 5 Feb 2006 05:04:12 +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 FAA06642 for ; Sun, 5 Feb 2006 05:04:12 +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 k1544BI9002653 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Sun, 5 Feb 2006 05:04:12 +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 k1544BYg027581 for ; Sun, 5 Feb 2006 05:04:11 +0100 Received: by first.in-berlin.de (Postfix, from userid 501) id 144D820F8DB; Sun, 5 Feb 2006 05:03:29 +0100 (CET) Date: Sun, 5 Feb 2006 05:03:28 +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: <20060205040328.GA5917@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 43E5793C.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 43E5793B.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 iterating:01 recursion:01 trivial:01 non-trivial:01 non-trivial:01 trivial:01 iterative: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, On Sun, Feb 05, 2006 at 12:36:53PM +1300, Jonathan Roewen wrote: > Where does the iterating come in? From your description, all you're > doing is a one-time calculation on a set of input values. u is calculated out of e and x with operator/function function_B. But e is calculated out of u with function_C So, there is a loop of calculation, which means that there is recursion... > > E.g. of the form: > > while true do > print_result (func_A (read_int ())) > done;; Yes, that's, what is the underlying thing: you get input values and create output values. But the calculation of output values is done via an internal feedback... > > Perhaps if you upload the circuit somewhere so people can see, it > might make a difference. OK, because sending it as an email-attachement didn't worked on this list, I put the picture here: http://www.belug.org/~ob/struktur-grafisch.jpg The first picture is the so called trivial machine, which only operates on the input with an operation/function and creates an output value; and the second picture in the file is the non-trivial machine (the simplest version of a non-trivial machine with one input value and the necessary feedback inside the machine). (Distinction between both is done because: the non-trivial machine is history dependnt, the trivial is not. Also there are differences in prediction of both: the trivial machine is time-independent and therefore easily to predict. But the non-trivial machine can't be tested/analyzed/predicted as like the trivial machine...) For the trivial machine I had done two implementations: one is iterative and uses the while-loop. And then I did a recursive implementation. For the trivial machine (first picture) I created the following code that is functional/recursive: (* -------------------------------------------- *) let function_A x = x * 2 let _ = let rec calc () = let inval = int_of_string (read_line()) (* input-value "x" in the picture *) in let outval = function_A inval (* Operator/Function "A" in the picture *) in Printf.printf "%d => %d \n" inval outval; calc() (* outval is "y" in the picture *) in calc () (* -------------------------------------------- *) For the non-trivial machine because of the feedbacks it's not so easy to write it as a program. IMHO FP has some advantages, because I do not need to store transitional valuthe necessaryes... but the recursions stuff.... welll, how to implement it here?! I had tried some ways (mutual recursive functions, mutual values and combinations, but I don't know what I really need and I need some help here....). TIA, Oliver