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 AAA08430; Fri, 12 Jul 2002 00:28:56 +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 AAA08426 for ; Fri, 12 Jul 2002 00:28:55 +0200 (MET DST) Received: from dewberry.cc.columbia.edu (dewberry.cc.columbia.edu [128.59.59.68]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g6BMSsD26856 for ; Fri, 12 Jul 2002 00:28:55 +0200 (MET DST) Received: from there (tw304h3.cpmc.columbia.edu [156.111.84.180]) by dewberry.cc.columbia.edu (8.9.3/8.9.3) with SMTP id SAA02692 for ; Thu, 11 Jul 2002 18:28:54 -0400 (EDT) Message-Id: <200207112228.SAA02692@dewberry.cc.columbia.edu> Content-Type: text/plain; charset="iso-8859-1" From: Oleg To: caml-list@inria.fr Subject: [Caml-list] Array.resize ? Date: Thu, 11 Jul 2002 18:30:24 -0400 X-Mailer: KMail [version 1.3.2] References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hi Is there an efficient way in O'Caml to append an element to an array ref? let append_elt r x = r := Array.append !r [| x |];; copies the contents of the whole array in its body, while e.g. C++ vector push_back in most cases won't (memory is reserved in chunks automatically, or it can be reserved manually) IOW it seems strange to me that functions of arrays can change their contents but not their size, while functions of array ref's can do it, but inefficiently. How about Array.resize : 'a array -> int -> unit or at least Array.resize: 'a array ref -> int -> unit ? Thanks Oleg ------------------- 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