English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] Breaking out of iterative loops
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-05-02 (12:31)
From: Alessandro Baretta <alex@b...>
Subject: Re: [Caml-list] Breaking out of iterative loops
Markus Mottl wrote:

> I second this. Does anybody here really benefit from such cyclic
> structures?

I feel it necessary to cite prof. Jean-Jacques Levy's course 
  on programming languages at the Ecole Polytechnique:

The following code illustrates how recursive data structures 
might be used to build a caml interpreter.

type expression = string

type variable_name = string

type values =
	Variable of variable_name
Const of int
Function of variable_name * expression * environment

and environment = (variable_name * values) list

The following is the internal representation the caml 
interpreter would build of
"let rec fact x = if x = 0 then 1 else x * fact (x-1)"

let rec rho =
   ["fact" , Function ("x", "if x=0 then 1 else x * fact 
(x-1)", rho)]

I hope this helps.


To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners