Re: [Camllist] From a recursive circuit to a functional/recursive OCamlcode...]
 Oliver Bandel
[
Home
]
[ Index:
by date

by threads
]
[ Message by date: previous  next ] [ Message in thread: previous  next ] [ Thread: previous  next ]
[ Message by date: previous  next ] [ Message in thread: previous  next ] [ Thread: previous  next ]
Date:  20060205 (04:04) 
From:  Oliver Bandel <oliver@f...> 
Subject:  Re: [Camllist] From a recursive circuit to a functional/recursive OCamlcode...] 
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 onetime 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 emailattachement didn't worked on this list, I put the picture here: http://www.belug.org/~ob/strukturgrafisch.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 nontrivial machine (the simplest version of a nontrivial machine with one input value and the necessary feedback inside the machine). (Distinction between both is done because: the nontrivial machine is history dependnt, the trivial is not. Also there are differences in prediction of both: the trivial machine is timeindependent and therefore easily to predict. But the nontrivial 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 whileloop. 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()) (* inputvalue "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 nontrivial 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