Home     About     Download     Resources     Contact us

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at ocaml.org.

Browse thread
From a recursive circuit to a functional/recursive OCaml-code...
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
 Date: 2006-02-04 (21:20) From: Oliver Bandel Subject: From a recursive circuit to a functional/recursive OCaml-code...
```
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

```