From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id UAA04323; Sun, 10 Aug 2003 20:51:01 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id UAA04530 for ; Sun, 10 Aug 2003 20:50:59 +0200 (MET DST) Received: from manzanita (63-217-154-71.greystoneapts.com [63.217.154.71]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h7AIowf22218 for ; Sun, 10 Aug 2003 20:50:58 +0200 (MET DST) Received: from ijtrotts by manzanita with local (Exim 3.36 #1 (Debian)) id 19lYln-0000H4-00 for ; Sat, 09 Aug 2003 11:48:51 -0700 Date: Sat, 9 Aug 2003 11:48:51 -0700 From: ijtrotts@ucdavis.edu To: caml-list@inria.fr Subject: Re: [Caml-list] Array.filter (was Multi-keyed lookup table?) Message-ID: <20030809184851.GA946@localhost> References: <005d01c35e51$7c927200$6628f9c1@zofo> <20030809165720.GE21525@swordfish> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030809165720.GE21525@swordfish> User-Agent: Mutt/1.5.4i X-Loop: caml-list@inria.fr X-Spam: no; 0.00; ijtrotts:01 caml-list:01 0600,:01 gushee:01 implemented:01 apis:01 struct:01 issac:01 trotts:01 davis:99 arrays:01 center:98 int:01 0200,:01 readable:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Sat, Aug 09, 2003 at 10:57:20AM -0600, Matt Gushee wrote: > On Sat, Aug 09, 2003 at 10:36:06AM +0200, Jean-Baptiste Rouquier wrote: > > >BTW, why isn't there an Array.filter function? > > There is a lot of such general purpose functions that one would like to have > > already implemented. But having all of these in the standard library would > > make it less readable. > > Sure. I just thought that lists and arrays are rather similar data > structures, and to the extent that they are similar, their respective > modules should have similar APIs. It might help to create a file (mods.ml) with your favorite additions and modifications to the standard library. Then you can open Mods in any files where the modifications are needed. # module Array = struct include Array let filter f a = Array.init (Array.length a) (fun i -> f a.(i)) end;; # Array.filter (fun x -> x * x) [| 1;2;3 |];; - : int array = [|1; 4; 9|] Hope this helps, Issac -- Issac Trotts Programmer Center for Neuroscience University of California, Davis ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners