From: Damien Doligez <damien.doligez@inria.fr>
To: caml users <caml-list@inria.fr>
Subject: Re: [Caml-list] generic Hashtbl.to_array
Date: Wed, 26 Jul 2006 11:48:25 +0200 [thread overview]
Message-ID: <C113E1F9-C02E-42EB-B6D3-63E98A8AFF96@inria.fr> (raw)
In-Reply-To: <20060726021615.4FF7DA9B1@Adric.metnet.fnmoc.navy.mil>
On 2006-07-26, at 04:16, oleg@pobox.com wrote:
> let to_array9 t =
> let Some (a,_) =
> Hashtbl.fold (fun k v seed ->
> match seed with
> Some (a,i) -> a.(i) <- (k,v); Some (a,i+1)
> | None -> let a = Array.make (Hashtbl.length t) (k,v) in
> Some (a,1))
> t None
> in a
> ;;
It fails whenever the hash table is empty, and the compiler
warns you about it. Replace your "let Some (a,_) = ..."
with a pattern-matching and you have a nice solution.
-- Damien
next prev parent reply other threads:[~2006-07-26 9:48 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-26 2:16 oleg
2006-07-26 9:48 ` Damien Doligez [this message]
-- strict thread matches above, loose matches on Subject: below --
2006-07-26 14:41 AW: [Caml-list] " Christoph Bauer
2006-07-26 14:53 ` Tom
2006-07-25 15:53 AW: AW: " Christoph Bauer
2006-07-25 16:35 ` Tom
2006-08-15 8:26 ` Stéphane Glondu
2006-07-25 12:44 AW: " Christoph Bauer
2006-07-25 15:20 ` Tom
2006-08-15 8:08 ` Stéphane Glondu
2006-07-25 12:00 Christoph Bauer
2006-07-25 16:19 ` skaller
2006-07-25 8:29 Christoph Bauer
2006-07-25 9:14 ` [Caml-list] " Erick Tryzelaar
2006-07-25 11:45 ` Damien Doligez
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=C113E1F9-C02E-42EB-B6D3-63E98A8AFF96@inria.fr \
--to=damien.doligez@inria.fr \
--cc=caml-list@inria.fr \
/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).