From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 93B3ABB9C for ; Sun, 18 Sep 2005 16:06:33 +0200 (CEST) Received: from mail.physik.uni-muenchen.de (mail.physik.uni-muenchen.de [192.54.42.129]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j8IE6X3j016427 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Sun, 18 Sep 2005 16:06:33 +0200 Received: from localhost (unknown [127.0.0.1]) by mail.physik.uni-muenchen.de (Postfix) with ESMTP id C678420014; Sun, 18 Sep 2005 16:06:32 +0200 (CEST) Received: from mail.physik.uni-muenchen.de ([127.0.0.1]) by localhost (mail.physik.uni-muenchen.de [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 11788-01-5; Sun, 18 Sep 2005 16:06:30 +0200 (CEST) Received: from mailhost.cip.physik.uni-muenchen.de (kaiser.cip.physik.uni-muenchen.de [141.84.136.1]) by mail.physik.uni-muenchen.de (Postfix) with ESMTP id D0F5E2000C; Sun, 18 Sep 2005 16:06:30 +0200 (CEST) Received: from eiger.cip.physik.uni-muenchen.de (eiger.cip.physik.uni-muenchen.de [141.84.136.54]) by mailhost.cip.physik.uni-muenchen.de (Postfix) with ESMTP id 4826926F4D; Sun, 18 Sep 2005 16:06:30 +0200 (CEST) Received: by eiger.cip.physik.uni-muenchen.de (Postfix, from userid 3092) id 4252712F75; Sun, 18 Sep 2005 16:06:30 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by eiger.cip.physik.uni-muenchen.de (Postfix) with ESMTP id 3D56A12F17; Sun, 18 Sep 2005 16:06:30 +0200 (CEST) Date: Sun, 18 Sep 2005 16:06:30 +0200 (CEST) From: Thomas Fischbacher To: Jonathan Roewen Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] lisp to ocaml In-Reply-To: Message-ID: References: X-BOFH: Daemons did it MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: amavisd-new at physik.uni-muenchen.de X-Miltered: at concorde with ID 432D7469.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 ocaml:01 ocaml:01 compiler:01 factorial:01 factorial:01 rec:01 parentheses:01 parentheses:01 syntax:01 parens:01 2005,:98 cip:98 cip:98 lambda:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_FAIL autolearn=disabled version=3.0.3 On Sun, 18 Sep 2005, Jonathan Roewen wrote: > Does anyone know of a tool that can convert lisp to ocaml (or > something other ML dialect)? For ANSI Common LISP, this could at best work at the level of a LISP interpreter (or compiler) written im ML. You cannot directly compile LISP code to ML code in the sense that (defun factorial (n) (labels ((walk (so-far todo) (if (= todo 0) so-far (walk (* so-far todo) (- todo 1))))) (walk 1 n))) would become let factorial n = let rec walk so_far todo = if todo=0 then so_far else walk (so_far*todo) (todo-1) in walk 1 n ;; for a ton of reasons. > Just all the parentheses gets a bit confusing for a first > look at lisp ;-) The trick is: (1) Do not look at the parentheses. Read and write code by indentation. (2) Use a text editor that helps you with this. (3) paren-sensitive syntax highlighting is a great thing. You will find the parens to be much less confusing once you learned not to look at them. :-) -- regards, tf@cip.physik.uni-muenchen.de (o_ Thomas Fischbacher - http://www.cip.physik.uni-muenchen.de/~tf //\ (lambda (n) ((lambda (p q r) (p p q r)) (lambda (g x y) V_/_ (if (= x 0) y (g g (- x 1) (* x y)))) n 1)) (Debian GNU)