... If I understand the problem correctly, what you need are called 'existential types'. OCaml doesn't have them directly, but you can emulate them using...
Hello ... Note that the type you've provided are indeed less general than required by the module's type signature, since when 'a is constraint by <cmp: 'a ->...
This question has been asked once before but had no replies: http://tech.groups.yahoo.com/group/ocaml_beginners/message/8722 Why does the following work under...
This is just a quick check. Have you tried giving the full path to open_process ? Or specify "./wish85" instead of just "wish85" ? IIRC the current directory...
... I think CamaradeTux nailed your problem with the $PATH. However I'd like to add that opening two channels like this isn't necessarily safe. You can easily...
C is my native language, so I translate everything from/to C so far. So, my question will probably looks ridiculous, but... Please don't laugh at me ! :-) ...
... Lots of possibilities for this. If you want a literal, fast translation then your array method isn't too bad, but ... ... int_of_fruit is faster if you...
-[ Sun, Jan 04, 2009 at 10:19:59PM +0000, Richard Jones ]---- ... Wow, what's that ? Let me guess : "external" mean that we are going to define a symbol...
... Yes. ... That's polymorphic variants. ... Not without meta-programming (camlp4 or else). You may also consider of solution of the following kind: let...
... I will avoid the solution given by R. W. M Jones, which works but is unsafe. FP programming (and in particular OCaml) allow to build directly compare...
... Hi Richard, could you join a license along with this module?...
Florent Monnier
fmonnier@...
Jan 5, 2009 9:29 am
10663
Le lun 05 jan 2009 00:35:10 CET, ... yes. But as Richard Jones said this is only valid as long as you have constant constructors in your type (i.e. it is...
... It's just a way to say that fruit_species can be treated directly as an integer. At this point you should read the infamous Chapter 18 of the manual: ...
-[ Mon, Jan 05, 2009 at 10:47:21AM +0100, Virgile Prevosto ]---- ... Yes it works but the problem with doing this in Ocaml is that NB_FRUITS would be treated...
-[ Mon, Jan 05, 2009 at 09:59:26AM +0000, Richard Jones ]---- ... I've started to read it. So %identity is a C function provided by the ocaml "environment"...
-[ Mon, Jan 05, 2009 at 07:46:41AM +0000, Sylvain Le Gall ]---- ... OK, I'm going to use a Map. With the troublesome impression of using a railgun to kill a...
... If you have an IDE that expands pattern matching and you'd like to provide initial values, this can be handy: let fruits_count f = match f with ... ;; incr...
... That's correct. Attached is an example of an 'enum' camlp4 extension. As discussed previously, you can write: enum fruits = Apple | Banana | Orange and the...
... I'm not sure if these internal functions are documented anywhere, but %identity is widely known and used. You'll find others if you read the source in...
... Yes, yes and yes. Notice what OCaml's Hashtbl.hash function does to the elements of your enumeration: # type t = Apple | Orange | Banana;; type t = Apple |...
Jon Harrop
jon@...
Jan 5, 2009 3:28 pm
10674
-[ Mon, Jan 05, 2009 at 03:31:42PM +0000, Jon Harrop ]---- ... Very interresting ! Is it by coincidence, or does Hashtbl.hash implementation for variants ...
-[ Mon, Jan 05, 2009 at 01:38:25PM +0100, Lukasz Stafiniak ]---- ... Not that I like it, but I find it clever. I'd never have though of that by myself....
... You'll still get collisions in the general case. Hashtbl.hash turns into a direct C function call to this function (with count = 10 and limit = 100 and...
Ooops! I'm so sorry, I've been obviously wrong! ... let fruits_count = let r1, r2, r3 = ref 0, ref 0, ref 5 in function ... ;; OK, now this is really ugly ;-)...
-[ Mon, Jan 05, 2009 at 08:36:51PM +0100, Lukasz Stafiniak ]---- ... I don't get the difference, Wouldn't the first fruits_count return the same ref if called...
-[ Mon, Jan 05, 2009 at 07:29:37PM +0000, Richard Jones ]---- ... Funny to fall back on C for handling the polymorphism :-) ... Yes but as this is my first...
... No, it wouldn't. [ref] is a function, [ref 0] creates a new reference cell the time it is computed. So, we need to create the reference cells when defining...