Hello, I've the following situation:
module type M = sig type s = ... end
module Make(P: Something) : (M with type s = P.t) = struct
type s = P.t
...
end
that works fine to generate modules of M type that use specific implementation of modules of type Something inside their implementation.
Now suppose I have another module de...
Hi all,
is there an OCaml equivalent to Haskell's pattern matching on an arbitrary number of arguments? For example, can I have something resembling:
merge [] lst = lst
merge lst [] = lst
merge l1 @ (n : ns) l2 @ (m : ms) =
if n < m then n : merge ns l2 else m : merge l1 ms
(The example's lifted from Developing Applications with O...
In C/C++ you can implement a direct threaded interpreter with an array of function pointers. The array represents your program - an array of operations. Each of the operation functions must end in a call to the next function in the array, something like:
void op_plus(size_t pc, uint8_t* data) {
*data += 1;
BytecodeArray[pc+1](pc+1...
Hello,
suppose I have a long algorithm which I would like to be optionally verbose to debug it. So far I just added many if verbose then printf "whatever" all around the code but this forces the code to execute many useless tests if I don't want to have it in the verbose mode.
Is there a way to obtain a simple conditional compilation wh...
I am writing OCaml code. In part of it, I want to examine whether two arithmetic expression are equal (like x+2+y == x+2*y-y+2). Implemeting this in mathematica is straightforward, so all I want some help on executing Mathematica and get the result back in OCaml. My OS platform is Linux.
Cheers,
Z.
...
Hello,
I'm searching for an good OCaml Tree tutorial...
...I need a few examples of how to remove elements, add elements, remove subtrees...
Br, Wolfy
...
Hi everyone. I've been learning Ocaml with lablgtk2 for a while and still searching for a tutorial in which describe a way to create a custom widget (I want to make this widget as a circle filled with color and some text in the center). And this custom widget can be set ~width, ~height, ~label, ~packing,... to another container (as anoth...
I'm sketching a design of something (machine learning of functions) that will preferably want a functional programming language, and also introspection, specifically the ability to examine the program's own code in some nicely tractable format, and preferably also the ability to get machine generated code compiled at runtime, and I'm won...
I'm having a problem calling an outside application from a compiled ocaml application, pdflatex. I'm using the proper string as an argument, when I run it from the toplevel I get the expected results,
Unix.system "pdflatex -interaction batchmode -output-directory res ALGO_GEN.tex";;
And it generates the proper output,
This is pdfTeX...
Coming to OCaml from Lisp, I find myself very confused about when functions return and when they don't. I miss my magic Quote! Thankfully, most of the time, OCaml appears to automagicly know when I want a function evaluated and when I don't. However, I frequently find myself trying to assign the return value of a function in a let exp...
Anyone know how to install Ocamlgraph library on Window?
I am using Ocaml install on Mingw port. Can't figure a way to do this?
...
I have a problem with compiling a program written in ocaml, the error appears to me is: Error: Unbound module Basics, how can I solve this problem?
I state that the beginner with this language.
libraries used throughout the code are:
open Basics ;;
open Paritygame ;;
open Univsolve;;
open Solvers;;
f...
Hello,
I wrote an application that needs to be compared with another one that does the same job.. mine is in OCaml while other one is in Java.
I would like to make two runs on the programs and monitor the RAM usage during the time elapsed by these executions. Both programs are really memory and cpu intensive so I'll have enough data to ...
Hi,
I am writing an OCaml function where I need to merge two maps. I have not been able to figure out the semantics of the merge function provided by functor Map.Make (found in version 3.12.0 of OCaml). Could someone provide me with a more detailed explanation than the OCaml manual? An example would probably enough for me to figure it o...
Haven't seen this "feature" anywhere else. I know that the 32nd bit is used for garbage collection. But why is it that way only for ints and not for the other basic types?
...
On a fresh Debian system (Squeeze/Sid) I have installed the following packages using apt-get:
ocaml-batteries-included
libpcre-ocaml-dev
libcamlnet-ssl-ocaml-dev
libldap-ocaml-dev
When compiling code I get errors such as:
ocamlfind: [WARNING] The DLL dllnetaccel_c.so occurs in multiple directories: /usr/lib/ocaml/stublibs
ocamlfind:...
What I want is to have the following source tree layout:
src/
a.ml
b.ml
...
tests/
a.ml
b.ml
...
Is it possible to distinct these modules and access
src/a.ml module as A and tests/a.ml module as something like Tests.A ?
Actually, there also is a problem with ocamlfind (UPD: omake) it thinks that tests/a.ml...
My problem is that ocamlc and ocamlopt apear to be refusing to find third party libraries installed through apt-get. I first started having this problem when I tried to incorporate third-party modules into my own OCaml programs, and quickly wrote it off as a personal failing in understanding OCaml compilation. Soon-- however-- I found my...
Hi,
I have been trying to figure out what I figure is a pretty simple task, namely adding entries to a map of Strings in OCaml from within a function. The relevant elements are below:
module StringMap = Map.Make (String);;
let m = StringMap.empty;;
let rec count ke = match ke with
|[] -> []
|hd::tl -> begin let m = StringMap.add hd...
Hi,
In the OCaml world at present there appear to be a number of competing extensions to the standard library, Batteries and Jane Street Core being the major ones as far as I can determine (I understand that ExtLib has been subsumed into Batteries?). What are the pros and cons of each one? Are they equivalent? Can they coexist? Does it ...