Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] lisp to ocaml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jon Harrop <jon@f...>
Subject: Re: [Caml-list] lisp to ocaml
On Sunday 18 September 2005 15:06, Thomas Fischbacher wrote:
> 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.

In this case, what else is needed beyond replacing operators with those 
suitable for a generalised numeric type and constructing numeric literals?

-- 
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
Objective CAML for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists