ocaml

Doing a N-dimensional walk in pure functional ML ?

The idea is to walk over multiple dimensions, each one defined as a range (* lower_bound, upper_bound, number_of_steps *) type range = real * real * int so functions like fun foo y x or fun foo z y x could be applied to the whole square X*Y or cube X*Y*Z. SML/NJ doesn't like my implementation below : test2.sml:7.5-22.6 Error: right-...

What to learn? Lisp or OCaml or...?

I already have a few languages under my belt (in a rough order of expertise): Python, C, C++, PHP, Javascript, Haskell, Java, MIPS, x86 assembler. But it's been almost 2 years since I learned a new one, and I'm starting to get the itch. I have a few criteria: Must (repeat: must) have a free Linux implementation Should be different from...

ocamlopt on Windows doesn't produce executable

Here's a simple OCaml program: helloworld.ml print_string "Hello world...\n" ;; I'm using OCaml 3.11.0 (MSVC built), VS 2008, and of course FlexDLL Here's how I compile it (ran from the VS 2008 shell): ocamlopt helloworld.ml -o helloworld No executable created. Is there something wrong? The program compiled and ran on Linux, though...

How do I inteface OCaml with iPhone API?

I'd like to start developing applications for iPhone, but I'd really like to use OCaml rather than Objective-C. After some googling, it seems like this is definitely possible, but I haven't found any code snippets which actually compile. Is it possible to write iPhone apps using OCaml? If so, could you provide a snippet demonstrating ho...

how do i configure/install jocaml on windows

The only instructions I could find are here: http://eigenclass.org/hiki/fast-widefinder and on the old jocaml site. When I try to configure using ./configure, it says jocaml and companion ocaml versions are mismatched. I tried using jocaml 3.11.0 and ocaml 3.11.0. How to go forward? I have read in the mailing lists that support for wi...

How to use multicores in Ocaml to do Monte Carlo simulations?

Ocaml process can use just one core and in order to use multiple cores I have to run several processes. Are there any Ocaml frameworks to use to parallelize Monte Carlo simulations? ...

Is INRIA going to add concurrency primitives to OCaml?

By "concurrency" I mean lightweight processes like Erlang's actors and concurrent GC aimed to make such a processes work smoothly. It would be very cool if INRIA got rid of those drawbacks of the current OCaml implementation to make OCaml more prepared for the multicore future. P.S. F# isn't what I'm looking for. ...

Erlang vs OCaml (best niche to fit)

Hi I'd like to pick up one FP language (it's always a pain when you work in a position that does not require you learn much), and after doing some research, I felt Erlang and OCaml are the two that I'd really like to get my feet wet for the following reasons: 1) I work mainly on high-availability web server back-end system in C++. I hea...

Compiling ocaml in notepad++

Hello. I'm learning OCaml at the moment and was wondering if it is possible to let Notepad++ take care of the interpreting of my scripts, and display the output in the compiler window? Thanks! ...

Implementing the following with OCaml

I'm trying to implement the following with OCaml for a homework assignment: g(n) = y if n = x else f(n) so, for example if f(n) = n+1, x = 7, y=42, then g(1) = 2, but g(7) = 42 I've got: # let update f x y = f(x) = y;; val update : ('a -> 'b) -> 'a -> 'b -> bool = < fun> but I just don't know the syntax I should use in order to ...

OCaml: How does List.fold_left work?

I'm trying to find the average of a list of floats. let avg l = List.fold_left ( +. ) 0 l /. List.length l;; How does List.fold_left work? (Applies the first argument to a list (the third arg)... but then what is the second argument?) Toplevel returns this error: Characters 43-44: List.fold_left ( +. ) 0 l /. List.length...

Ocaml "Out of memory" exception; verbose mode says "Stack overflow in structural comparison"

A very huge ocaml program from an alien source needs to be fixed. One of the problem is that the program crashes at seemingly innocent line: Hashtbl.mem loc_to_no loc with "Out of memory" exception. The thing is that there's surely enough memory out there and this line is executed just fine for other inputs and even earlier during t...

OCaml: Why does this code produce a type check error?

Here is my code: let avg l = List.fold_left ( +. ) 0. l /. float (List.length l);; let variability l = let xbar = avg l in let odp = (List.map (fun i -> ((float) i -. xbar) ** 2.0) l) in let sum = List.fold_left ( +. ) 0. odp in sum /. (float) length l;; Entering this into the toplevel produces the following: val...

What OCaml libraries are there for lazy list handling?

What OCaml libraries are out there that provide lazy list handling? I am looking for something along these lines: type 'a lazy_list = (*'*) | Nil | Cons of 'a * 'a lazy_list lazy_t let from f = let rec gen n = lazy ( match f n with | Some x -> Cons (x, gen (n + 1)) | None ->...

Does != have meaning in OCaml?

It seems to be an equivalency comparison for some types, but not strings. # 3 != 3;; - : bool = false # 3 != 2;; - : bool = true This is as expected. # "odp" = "odp";; - : bool = true # "odp" != "odp";; - : bool = true # "odp" <> "odp";; - : bool = false Why does "odp" != "odp" evaluate to true? What is it actually doing? Shouldn't...

What other OCaml top level programs exist? (Vista)

I'm using OCamlWinPlus v1.9RC4. It sucks pretty hardcore. It's constantly crashing, and lacks basic features. What other toplevel OCaml programs can be recommended for Windows Vista? ...

OCaml: Check a list of records for membership

If I have defined the following types: type category = Noun | Verb | Adjective | Preposition;; type transformation = {start: category; fin: category};; What is the best way to answer the question "is the record where start = Noun in the list of type transformation? Sort of like let un = [{start= Noun; fin= Noun}; {start= Verb; fin= ...

OCaml: Leaving fields in records undefined?

I have this record type: type syllable = {onset: consonant list; nucleus: vowel list; coda: consonant list};; What if I want to instantiate a syllable where only the nucleus is defined? Can I give it a default value? Does it default to [] or something like that? ...

OCaml: Default values for function arguments?

In PHP, default values for arguments can be set as follows: function odp(ftw = "OMG!!") { //... } Is there similar functionality in OCaml? ...

OCaml: List that could contain two types?

Instead of specifying a int list or string list, could I specify a list whose members must be either strings or ints, but nothing else? ...