Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Oliver Bandel <oliver@first.in-berlin.de>
To: caml-list@inria.fr
Subject: Re: [Caml-list] From a recursive circuit to a functional/recursive OCaml-code...]
Date: Sun, 5 Feb 2006 05:03:28 +0100	[thread overview]
Message-ID: <20060205040328.GA5917@first.in-berlin.de> (raw)

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


                 reply	other threads:[~2006-02-05  4:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060205040328.GA5917@first.in-berlin.de \
    --to=oliver@first.in-berlin.de \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox