Questions tagged [ocaml]

OCaml is a strict statically-typed functional programming language, focusing on expressiveness, correctness, and efficiency.

#OCaml

OCaml is a strict statically-typed functional programming language, focusing on expressivity, correctness, and efficiency. These qualities make it the language of choice for complex software and timely go-to-market strategies.

For more information visit, the official OCaml site.

##Resources for OCaml Developers

##Resources for learning OCaml

Stack Overflow OCaml FAQ

  1. Documentation
  1. Editor
  1. The core language
  1. Loops/recursion
  1. Tools
  1. Good practices

#See also:#

7516 questions
4
votes
2 answers

"The cma file is not a bytecode object file" => What does that mean?

I'm trying to install the ocaml-sqlite3 bindings, to access a sqlite database from an o'caml program. The configure and make go smoothly, but the installation fails. Because the file sqlite3.cma is not a bytecode object file (see below). …
LB40
  • 12,041
  • 17
  • 72
  • 107
4
votes
2 answers

Can an OCaml program use more than one processor core?

Isn't it important to be able to do that in order to attain maximal speed? Edit: Clojure, for example, has pmap, which uses more than one core. Dr. Harrop wrote (Jan. 9, 2011): The new features being added to the language, such as…
to_the_crux
  • 257
  • 1
  • 6
4
votes
3 answers

How to download and install Emacs for OCaml?

I feel retarded asking this question, but I've been banging my head against the wall for a while now... This directory is linked to by the website for obtaining emacs: http://ftp.gnu.org/pub/gnu/emacs/. Which file do I want? I downloaded…
Nick Heiner
  • 119,074
  • 188
  • 476
  • 699
4
votes
3 answers

OCaml: bound expressions v. functions

Here we have a function definition: let f x = x + 3;; Here is an expression: let g = 4;; Could g just be thought of as constant function that takes no arguments? Is there any difference?
Nick Heiner
  • 119,074
  • 188
  • 476
  • 699
4
votes
2 answers

ocaml sprintf clarification

I do not understand why this is the case: Printf.sprintf "%08s" "s" = Printf.sprintf "%8s" "s" - : bool = true In other words, I would expect: Printf.sprintf "%08s" "s" - : string = "0000000s" and not the actual result: - : string = " …
mbunit
  • 463
  • 3
  • 10
4
votes
1 answer

Parser/Lexer ignoring incomplete grammar rules

I have a parser and lexer written in ocamlyacc and ocamllex. If the file to parse ends prematurely, as in I forget a semicolon at the end of a line, the application doesn't raise a syntax error. I realize it's because I'm raising and catching EOF…
nlucaroni
  • 47,556
  • 6
  • 64
  • 86
4
votes
2 answers

How to install Cohttp with lwt support?

Running opam install cohttp does not provide me with cohttp.lwt in findlib. Am I missing a command line option to install with lwt support?
rgrinberg
  • 9,638
  • 7
  • 27
  • 44
4
votes
2 answers

Find at least one element that exists in all three lists in OCaml

We have three lists which contain people's names. All three lists have been sorted alphabetically. Now we need to find at least one name which appear in all three lists. The algorithm I am thinking is like this: I get three heads out of three…
Jackson Tale
  • 25,428
  • 34
  • 149
  • 271
4
votes
3 answers

Is it possible to make this fully polymorphic in OCaml?

in OCaml let nth_diff_type i (x, y, z) = match i with 1 -> x |2 -> y |3 -> z |_ -> raise (Invalid_argument "nth") So the current type is int->('a,'a,'a)->'a, right? It implies that x, y, z must have the…
Jackson Tale
  • 25,428
  • 34
  • 149
  • 271
4
votes
3 answers

List.fold_left in OCaml

I wrote a function, which adds all elements from the given list: let rec add = function []->0 | h::t->h+add(t);; Now I want to write the same function, but using List.fold_left, but I tried several changes but I still have an error. First I tried…
Ziva
  • 3,181
  • 15
  • 48
  • 80
4
votes
1 answer

OCaml sexplib, how to define custom to_sexplib function?

I'm using with sexp syntax to generate s-exp functions automagically. The problem is data structures I'm printing with sexplib have some recursive pointers and printing will end up with stack overflow. So I need to override a to_sexp function and…
sinan
  • 6,809
  • 6
  • 38
  • 67
4
votes
3 answers

How to write a pattern match in Ocaml so it is easy to scale?

I am learning Jason Hickey's Introduction to Objective Caml. There is an exercise like this: Exercise 4.3 Suppose we have a crypto-system based on the following substitution cipher, where each plain letter is encrypted according to the following…
Jackson Tale
  • 25,428
  • 34
  • 149
  • 271
4
votes
1 answer

What is the meaning of `abstract` in the `interface definition`?

I quite don't understand how the interface thing works in OCaml. Let's see an example: About the 'a So what the meaning of 'a here? I mean I understand that when describing the functions, 'a means arbitrary type. Then what's its meaning here? Does…
Jackson Tale
  • 25,428
  • 34
  • 149
  • 271
4
votes
1 answer

A simple OCaml program

I want to learn a bit of OCaml, just to get a taste of a programming language other than C++ and Java. I will be very greatful if you help me with the following program: basically the user inputs a positive integer. The sum of all integers from N to…
Stanimirovv
  • 3,064
  • 8
  • 32
  • 56
4
votes
1 answer

Parse a string by Lexing.from_string

I have implemented this example, and it works well. Now, I want to read from a string instead of reading from stdin, so I change the calc.ml: let _ = try let lexbuf = Lexing.from_string "1+3" in let result = Parser.main Lexer.token lexbuf…
SoftTimur
  • 5,630
  • 38
  • 140
  • 292
1 2 3
99
100