From: skaller <skaller@users.sourceforge.net>
To: hans@simula.no
Cc: Thomas Fischbacher <Thomas.Fischbacher@Physik.Uni-Muenchen.DE>,
caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Lazy recomputing
Date: 02 Jun 2004 03:39:55 +1000 [thread overview]
Message-ID: <1086111595.16811.134.camel@pelican.wigram> (raw)
In-Reply-To: <200406011722.15467.hans@simula.no>
On Wed, 2004-06-02 at 01:22, Hans Ole Rafaelsen wrote:
> let _ =
> List.iter
> (fun (k,v) -> Hashtbl.add tbl k v)
> [
> ("a", fun () -> 1);
> ("c", fun () -> ((Hashtbl.find tbl "b") ()) + ((Hashtbl.find tbl "a")
> ()));
> ("b", fun () -> 4);
> ]
Of course, this will recompute the same result needlessly
to make sure it also computes the new result when needed.
Also the functions are bound to a particular hashtble,
which isn't so nice: might be nicer to write:
fun tbl -> find tbl "b" + find tbl "a"
and
let eval tbl key = find tbl key tbl;;
let tbl = create 97;;
let eval_tbl key = eval tbl key;;
--
John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850,
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net
-------------------
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
prev parent reply other threads:[~2004-06-01 17:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-06-01 10:07 Hans Ole Rafaelsen
2004-06-01 11:43 ` Thomas Fischbacher
2004-06-01 12:59 ` skaller
2004-06-01 15:22 ` Hans Ole Rafaelsen
2004-06-01 17:39 ` skaller [this message]
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=1086111595.16811.134.camel@pelican.wigram \
--to=skaller@users.sourceforge.net \
--cc=Thomas.Fischbacher@Physik.Uni-Muenchen.DE \
--cc=caml-list@inria.fr \
--cc=hans@simula.no \
/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