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 IAA22304; Thu, 2 Oct 2003 08:09:49 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id IAA22953 for ; Thu, 2 Oct 2003 08:09:48 +0200 (MET DST) Received: from eth0.b.smtp.sonic.net (eth0.b.smtp.sonic.net [64.142.19.4]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h9269j508445 for ; Thu, 2 Oct 2003 08:09:46 +0200 (MET DST) Received: from oak.ramandgita.com.sonic.net (adsl-209-204-144-113.sonic.net [209.204.144.113]) by eth0.b.smtp.sonic.net (8.12.10/8.12.7) with ESMTP id h9269hOv001633 for ; Wed, 1 Oct 2003 23:09:44 -0700 From: Ram Bhamidipaty MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16251.48822.166307.867159@oak.ramandgita.com> Date: Wed, 1 Oct 2003 22:59:18 -0700 (PDT) To: caml-list@pauillac.inria.fr Subject: [Caml-list] beginner needs help creating a dynamically resizable array X-Mailer: VM 6.47 under 21.1 (patch 14) "Cuyahoga Valley" XEmacs Lucid X-Loop: caml-list@inria.fr X-Spam: no; 0.00; sonic:99 dynamically:01 dynamically:01 resize:01 resize:01 ocaml:01 mutable:01 mutable:01 int:01 int:01 buf:01 buf:01 module:03 let:04 let:04 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk I am trying to create a dynamically resizable array. So far this is what I have: type 'a darray = { mutable size_of_buf : int; mutable num_in_buf : int; mutable buf : 'a array; } ;; let create t = { size_of_buf=20; num_in_buf=0; buf = Array.make 20 t; } ;; I want to create a function that can resize this array. I want the function to look something like this: let resize dyn_array_ref new_size = ;; The function resize should table a reference to a darray record, and an int that specifies the new desired size of the array. There should be no return value. The problem I am running into is that I don't know how to create a new larger array of the same time as the original array. The only two choices that I can think of are: 1. Somehow store the type of the array in the record or 2. Somehow get the array element type from the "buf" array in the record. Unfortunately I have no idea about how to do either 1 or 2. I know there is atleast one package/module that provides this functionality. But I don't want to use someone elses code - I am trying to learn OCaml and I think this would be a good thing to do with my own code. Any help will be appreciated. -Ram ------------------- 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