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
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
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
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
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
>
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
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
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-
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
-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
-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
-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
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
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))
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
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
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'
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
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
=
Call for Participation
The 13th ACM SIGPLAN International Conference
on Functional Programming (ICFP 2008)
http://www.icfpconference.org/icfp2008
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
21 matches
Mail list logo