Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: "Ian Oversby" <oversby@hotmail.com>
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	[thread overview]
Message-ID: <BAY114-F191740E9768F12D5C51FD7A9C60@phx.gbl> (raw)
In-Reply-To: <45946E13.20708@fmf.uni-lj.si>

>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


  reply	other threads:[~2006-12-29  9:58 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20061203110003.6804FBC6A@yquem.inria.fr>
2006-12-28 11:42 ` Ian Oversby
2006-12-28 16:26   ` [Caml-list] " Jon Harrop
2006-12-28 17:13     ` skaller
2006-12-29  6:05       ` Jacques Garrigue
2006-12-29 11:15         ` Mattias Engdegård
2007-01-06  0:52           ` Nathaniel Gray
2007-01-06  1:01             ` Philippe Wang
2007-01-06  1:15             ` brogoff
2007-01-06  2:27               ` Martin Jambon
2007-01-08 22:23                 ` Nathaniel Gray
2006-12-28 19:24   ` Manfred Lotz
2006-12-29  1:23   ` [Caml-list] " Andrej Bauer
2006-12-29  9:58     ` Ian Oversby [this message]
2006-12-29  2:07   ` Jon Harrop
2007-01-03 16:43     ` Serge Aleynikov
     [not found] <15946.213.30.139.86.1167315231.squirrel@webmail.nerim.net>
2006-12-28 16:03 ` Ian Oversby
2006-12-28 17:00   ` Richard Jones
2006-12-28 22:23   ` Jon Harrop
2006-12-29  9:42     ` Ian Oversby

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BAY114-F191740E9768F12D5C51FD7A9C60@phx.gbl \
    --to=oversby@hotmail.com \
    --cc=Andrej.Bauer@andrej.com \
    --cc=caml-list@yquem.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox