Re: [Caml-list] Getting an element of a hashtable: simple ... or is it?

2008-08-05 Thread Brighten Godfrey
On Aug 5, 2008, at 5:25 AM, blue storm wrote: With Extlib you can use : let get_one hashtbl = Enum.peek (Hashtbl.enum hashtbl) val get_one : ('a, 'b) Hashtbl.t -> ('a * 'b) option Ah, thanks. On Aug 5, 2008, at 6:21 AM, Peng Zang wrote: I think this is pretty standard. At least, I see it in

Re: [Caml-list] Getting an element of a hashtable: simple ... or is it?

2008-08-05 Thread Chris Kauffman
I'm curious what sort of scenario calls for retrieving any single element of a hash table (which is potentially empty?). It seems most of the cases I deal with involve simply storing or iterating over all the elements. Cheers, Chris ___ Caml-list mailin

Re: [Caml-list] [camlp4] expr_of_string, string_of_expr functions exist?

2008-08-05 Thread Christophe TROESTLER
On Tue, 5 Aug 2008 17:04:26 +0100, Richard Jones wrote: > > Maybe a simple question, but does camlp4 have functions to turn > expr and patt AST structures to and from strings? Parsing: open Camlp4.PreCast let loc = Loc.ghost;; Syntax.AntiquotSyntax.parse_expr loc "x = 1";; Synta

Re: [Caml-list] [camlp4] expr_of_string, string_of_expr functions exist?

2008-08-05 Thread Yitzhak Mandelbaum
I don't know about the new camlp4, but in the old one the code looked something like this (where my AST is a list of str_item-s): open Pcaml let ast_to_strings ast = List.map (function str_item -> string_of pr_str_item str_item) ast --Yitzhak On Aug 5, 2008, at 12:04 PM, Richard Jones wrot

Re: [Caml-list] parameter passing optimizations

2008-08-05 Thread Stéphane Glondu
Warren Harris wrote: > I've been wondering whether the ocaml compiler does any sort of > parameter passing optimizations for data structures, e.g. stack > allocating, or destructuring them when it can determine their scope does > not escape the call. My first conclusion is that it does for tuples >

[Caml-list] Your email requires verification verify#lDvFUUSYGhpbQzAEYXZQlsBnwYh9u8d6

2008-08-05 Thread club
The message you sent requires that you verify that you are a real live human being and not a spam source. To complete this verification, simply reply to this message and leave the subject line intact. The headers of the message sent from your address are shown below: >From |[EMAIL PROTECTED] Tu

[Caml-list] parameter passing optimizations

2008-08-05 Thread Warren Harris
I've been wondering whether the ocaml compiler does any sort of parameter passing optimizations for data structures, e.g. stack allocating, or destructuring them when it can determine their scope does not escape the call. My first conclusion is that it does for tuples only, but I wanted to

[Caml-list] [camlp4] expr_of_string, string_of_expr functions exist?

2008-08-05 Thread Richard Jones
Maybe a simple question, but does camlp4 have functions to turn expr and patt AST structures to and from strings? Rich. -- Richard Jones Red Hat ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-

[Caml-list] Private and type constraints

2008-08-05 Thread Dario Teixeira
Hi, With 'private', you can make sure that users of a module can only use constructors to create values, while at the same type maintaining the ability to pattern-match (which abstracting the type makes impossible). With 3.10, this can also be done with polymorphic variants: module Foobar: sig

Re: [Caml-list] Error: This function is applied to too many arguments, maybe you forgot a `; '

2008-08-05 Thread Peng Zang
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Tuesday 05 August 2008 08:11:40 am Richard Jones wrote: > On Sun, Aug 03, 2008 at 08:46:32PM -0400, Ben Aurel wrote: > > print_int fac(6);; > > Read this: http://www.ocaml-tutorial.org/the_basics > > Rich. Second that. You really should take a l

Re: [Caml-list] newbie: how to call a function with multiple parameters?

2008-08-05 Thread Peng Zang
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 You don't pass arguments like you do in C or Java. In those languages you might do: somefunction(arg1, arg2, arg3) In OCaml, you do: somefunction arg1 arg2 arg3 In OCaml, "(arg1, arg2, arg3)" means create a 3-tuple. "somefunction(arg1, arg2

Re: [Caml-list] Getting an element of a hashtable: simple ... or is it?

2008-08-05 Thread Peng Zang
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 I think this is pretty standard. At least, I see it in ExtLib and I do it on a regular basis. In fact I have a function to do this for me so I don't have to do it over and over again. Eg. let get_one ht = mkGetOne Hashtbl.iter ht Peng On Tues

Re: [Caml-list] Error: This function is applied to too many arguments, maybe you forgot a `; '

2008-08-05 Thread Richard Jones
On Sun, Aug 03, 2008 at 08:46:32PM -0400, Ben Aurel wrote: > print_int fac(6);; Read this: http://www.ocaml-tutorial.org/the_basics Rich. -- Richard Jones Red Hat ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mail

Re: [Caml-list] Getting an element of a hashtable: simple ... or is it?

2008-08-05 Thread Brighten Godfrey
On Aug 5, 2008, at 5:16 AM, Richard Jones wrote: On Tue, Aug 05, 2008 at 05:05:46AM -0700, Brighten Godfrey wrote: Suppose you are given a data structure, and you want to retrive one element -- any one element. Sounds simple... and it is, if you have a list (List.hd list) or an array (arr.(0))

Re: [Caml-list] Getting an element of a hashtable: simple ... or is it?

2008-08-05 Thread blue storm
With Extlib you can use : let get_one hashtbl = Enum.peek (Hashtbl.enum hashtbl) val get_one : ('a, 'b) Hashtbl.t -> ('a * 'b) option ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: h

Re: [Caml-list] Getting an element of a hashtable: simple ... or is it?

2008-08-05 Thread Richard Jones
On Tue, Aug 05, 2008 at 05:05:46AM -0700, Brighten Godfrey wrote: > Suppose you are given a data structure, and you want to retrive one > element -- any one element. Sounds simple... and it is, if you have > a list (List.hd list) or an array (arr.(0)). But how about a > hashtable, if we don

[Caml-list] Getting an element of a hashtable: simple ... or is it?

2008-08-05 Thread Brighten Godfrey
Hi, Suppose you are given a data structure, and you want to retrive one element -- any one element. Sounds simple... and it is, if you have a list (List.hd list) or an array (arr.(0)). But how about a hashtable, if we don't know a priori any of the keys in the hashtable? The best way I'

Re: [Caml-list] newbie: how to call a function with multiple parameters?

2008-08-05 Thread micha
On Monday 04 August 2008 20:32:36 Ben Aurel wrote: > hi > yeah - the question is low, but I-m struggling on different frontiers > > Questions: > (* Q1 *): Somehow I don't get the concept with ";" and ";;". On line > 4 do I need to end the statement with semicolon double-semicolon or > nothing? th

Re: [Caml-list] newbie: how to call a function with multiple parameters?

2008-08-05 Thread asmadeus77
Hello, semicolons are separator inside sentences, that is, just like in C (you've had theses right) double semicolons are to tell the compiler you're ending a sentence; theses can be ommited when there is no ambiguity in the syntax, that is when there is another "main" let after it. Here, you need

[Caml-list] ICFP08 Call for Participation

2008-08-05 Thread Matthew Fluet (ICFP Publicity Chair)
= Call for Participation The 13th ACM SIGPLAN International Conference on Functional Programming (ICFP 2008) http://www.icfpconference.org/icfp2008

[Caml-list] newbie: how to call a function with multiple parameters?

2008-08-05 Thread Ben Aurel
hi yeah - the question is low, but I-m struggling on different frontiers /// print_logic.ml /// 1 let print_logic a b = 2 Printf.printf "a and b is %B\n" (a && b); 3 Printf.printf "a or b is %B\n" (a || b); 4 Printf.p