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=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 8FF54BB83 for ; Sat, 9 Sep 2006 09:57:13 +0200 (CEST) Received: from smtp.syd.people.net.au (smtp.syd.people.net.au [218.214.225.98]) by nez-perce.inria.fr (8.13.6/8.13.6) with SMTP id k897v5Gv002272 for ; Sat, 9 Sep 2006 09:57:12 +0200 Received: (qmail 3552 invoked from network); 9 Sep 2006 07:57:05 -0000 Received: from unknown (HELO coltrane.mega-nerd.net) (218.214.64.136) by smtp.syd.people.net.au with SMTP; 9 Sep 2006 07:57:05 -0000 Received: from coltrane (coltrane [192.168.1.101]) by coltrane.mega-nerd.net (Postfix) with SMTP id C7CB07ADA for ; Sat, 9 Sep 2006 17:56:52 +1000 (EST) Date: Sat, 9 Sep 2006 17:56:52 +1000 From: Erik de Castro Lopo To: caml-list@inria.fr Subject: Re: [Caml-list] Memoization Message-Id: <20060909175652.93b8d71d.mle+ocaml@mega-nerd.com> In-Reply-To: <45023723.2050708@andrej.com> References: <20060909103332.0397efea.mle+ocaml@mega-nerd.com> <45023723.2050708@andrej.com> Organization: Erik Conspiracy Secret Labs X-Mailer: Sylpheed version 2.2.6 (GTK+ 2.8.18; i486-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 450273D1.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; ocaml:01 memoization:01 andrej:01 higher-order:01 andrej:01 hashtbl:01 memoize:01 integers:01 memoize:01 cheers:01 wrote:01 polymorphic:01 arbitrary:01 caml-list:01 functions:01 Andrej Bauer wrote: > I use the code below to show my students what can be done with > higher-order functions. For a real implementation, we would have to use > something more efficient than association lists (but then you might end > up writing a polymorphic version of the Map module). Improvements are > welcome. Thanks Andrej, thats interesting. Is there any reason you didn't use a Hashtbl instead of the association list? I don't really think the the ordering of the Map module is needed. The particular function I'm trying to memoize is a function of two integers. I was hoping it might be possible to write a memoize function that memoizes any function of a small arbitrary number of parameters. Thinking about it some more I'm beginning to this this is not possible. Cheers, Erik -- +-----------------------------------------------------------+ Erik de Castro Lopo +-----------------------------------------------------------+ Saying Python is easier than C++ is like saying that turning a light switch on or off is easier than operating a nuclear reactor.