From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: ** X-Spam-Status: No, score=2.5 required=5.0 tests=AWL,DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST,MSGID_FROM_MTA_HEADER,SPF_SOFTFAIL autolearn=disabled version=3.1.3 Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id F0B86BC0B for ; Fri, 29 Dec 2006 10:58:23 +0100 (CET) Received: from bay0-omc2-s20.bay0.hotmail.com (bay0-omc2-s20.bay0.hotmail.com [65.54.246.156]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id kBT9wMtU014742 for ; Fri, 29 Dec 2006 10:58:23 +0100 Received: from hotmail.com ([65.54.169.29]) by bay0-omc2-s20.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.2668); Fri, 29 Dec 2006 01:58:22 -0800 Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Fri, 29 Dec 2006 01:58:22 -0800 Message-ID: Received: from 65.54.169.200 by by114fd.bay114.hotmail.msn.com with HTTP; Fri, 29 Dec 2006 09:58:19 GMT X-Originating-IP: [141.228.106.136] X-Originating-Email: [oversby@hotmail.com] X-Sender: oversby@hotmail.com In-Reply-To: <45946E13.20708@fmf.uni-lj.si> From: "Ian Oversby" To: Andrej.Bauer@andrej.com, caml-list@yquem.inria.fr Subject: Re: [Caml-list] Question on writing efficient Ocaml. Date: Fri, 29 Dec 2006 09:58:19 +0000 Mime-Version: 1.0 Content-Type: text/plain; format=flowed X-OriginalArrivalTime: 29 Dec 2006 09:58:22.0424 (UTC) FILETIME=[DFF5E580:01C72B2F] X-j-chkmail-Score: MSGID : 4594E6BE.002 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 4594E6BE.002 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 ocaml:01 translated:01 bug:01 cheers:01 blog:98 wrote:01 wrote:01 caml-list:01 algorithm:01 int:01 int:01 snip:02 algorithmic:02 hotmail:97 >Dear Ian, > >your ocaml code is quite "unusual", and I must say I am not convinced your >C++ code is written optimally (but I don't know anything about C++). I'm not convinced it is optimal either - I wrote the scheme version first and then translated first into Ocaml and then to C++. It is my first piece of Ocaml (and hopefully not the last) which probably accounts for the unusualness. >I transcribed your C++ version to a reasonable ocaml version. Please >compare what you did with how I transliterated your C++ code (attached file >queen.ml). In particular, I use more obvious types (position is just >int*int, a board is a 2D array) > >Then I wrote my own ocaml version which mimicks your algorithm, except that >instead of creating new boards all the time, it just keeps a list of >current positions of queens (attached file queen2.ml). Excellent. Thanks very much. I'll have a look at both of them and see what I can learn. >By the way, why are you placing 8 queens on the board, no matter how large >the board is? I thought the idea was to put n queens on a board of size n x >n. Yes, good catch - it is a bug. I didn't do sufficient testing. [snip] >Feel free to post this on your blog. Thanks again. I'll probably write a follow-up when I understand what is going on. Jon Harrop also uncovered an algorithmic difference between the C++ and the Ocaml so I'll look into that too. Cheers, Ian _________________________________________________________________ MSN Hotmail is evolving – check out the new Windows Live Mail http://ideas.live.com