caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Michal Moskal <malekith@pld-linux.org>
To: Ram Bhamidipaty <ramb@sonic.net>
Cc: caml-list@pauillac.inria.fr
Subject: Re: [Caml-list] beginner needs help creating a dynamically resizable array
Date: Thu, 2 Oct 2003 08:58:15 +0200	[thread overview]
Message-ID: <20031002065815.GA3921@roke.freak> (raw)
In-Reply-To: <16251.48822.166307.867159@oak.ramandgita.com>

On Wed, Oct 01, 2003 at 10:59:18PM -0700, Ram Bhamidipaty wrote:
> I am trying to create a dynamically resizable array. 
[...]
> let resize dyn_array_ref new_size =
[...]
> 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.

You can fill your array with *value* buf.{0}. You don't need its
type. This will present some odds for the GC, but if it's for educational
purposes then it's OK. The other way is Obj.magic trickery...

> 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.

...and for this reason I personally don't think it's best example to
learn OCaml on.

-- 
: Michal Moskal :: http://www.kernel.pl/~malekith : GCS {C,UL}++++$ a? !tv
: When in doubt, use brute force. -- Ken Thompson : {E-,w}-- {b++,e}>+++ h

-------------------
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


  reply	other threads:[~2003-10-02  7:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-02  5:59 Ram Bhamidipaty
2003-10-02  6:58 ` Michal Moskal [this message]
2003-10-02  7:26 ` Nicolas Cannasse
2003-10-02  9:58 ` Markus Mottl

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=20031002065815.GA3921@roke.freak \
    --to=malekith@pld-linux.org \
    --cc=caml-list@pauillac.inria.fr \
    --cc=ramb@sonic.net \
    /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;
as well as URLs for NNTP newsgroup(s).