From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id OAA04599; Thu, 2 May 2002 14:31:58 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 OAA04593 for ; Thu, 2 May 2002 14:31:57 +0200 (MET DST) X-SPAM-Warning: Sending machine is listed in blackholes.five-ten-sg.com Received: from athlonbaretta.richardginori1735.com ([62.211.4.193]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g42CVpX05812 for ; Thu, 2 May 2002 14:31:56 +0200 (MET DST) Received: from baretta.com (localhost.localdomain [127.0.0.1]) by athlonbaretta.richardginori1735.com (Postfix) with ESMTP id 5E3DF2724F for ; Thu, 2 May 2002 16:35:31 +0200 (CEST) Message-ID: <3CD14EB3.7000107@baretta.com> Date: Thu, 02 May 2002 16:35:31 +0200 From: Alessandro Baretta Organization: Baretta srl -- www.baretta.com User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0rc1) Gecko/20020417 X-Accept-Language: it, en MIME-Version: 1.0 To: Ocaml Subject: Re: [Caml-list] Breaking out of iterative loops References: <20020430202706.GA6791@vincent> <200204302331.32905.johan.baltie@wanadoo.fr> <3CD08EE3.9010202@ozemail.com.au> <863cxbmgww.fsf@laurelin.dementia.org> <20020502083335.GB16030@fichte.ai.univie.ac.at> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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: (http://www.enseignement.polytechnique.fr/informatique/M2/lp/). 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. Alex ------------------- 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