ocaml Questions

3

Solved

The french Sécurité Sociale identification numbers end with a check code of two digits. I have verified that every possible common transcription error can be detected, and found some other kinds of...
Bedplate asked 5/2, 2015 at 20:29

3

Solved

I'm trying to get an OCaml environment set up, and I've followed the instructions from appendix A of the Real World OCaml beta. I set up opam, and installed a version of OCaml with the command $ op...
Quartet asked 15/7, 2013 at 1:48

1

Solved

dune will generate and update a project's .opam file when you run dune build, letting you just manage the project's dependencies in dune-project. However, this seems to require an awkward step when...
Witter asked 9/4, 2023 at 20:44

13

Solved

This is what I have so far. Isn't this all that you need? I keep getting the error "Error: Unbound module Std" let r file = let chan = open_in file in Std.input_list (chan)
Sholes asked 25/4, 2011 at 3:37

4

Is there a way to create a polymorphic add function in OCaml that works equally well for ints and floats? So for example if I have a function like: partialsums [1; 2; 3; 4; 5] I should get [1; 3; ...
Freeholder asked 8/6, 2016 at 5:57

5

Solved

I need an OCaml map with keys of type int so I am using Map.Make to create one. However it seems that the standard modules 'only' provide modules like Big_int, Int32, Int64 and Nativeint which requ...
Stoss asked 12/4, 2012 at 21:2

11

Solved

I want to do something as simple as this: Print a list. let a = [1;2;3;4;5] How can I print this list to Standard Output?
Odawa asked 3/2, 2012 at 20:16

2

Solved

I am looking for a code formatter or pretty printer for ocaml. Something like gofmt for the go programming language. It should preferably preserve comments. I am correcting hand-ins and some of th...
Falsecard asked 9/10, 2012 at 11:7

4

Solved

I'm interested in using OCaml for a project, however I'm not sure about where its parallelization capabilities are anymore. Is there a message passing ability in OCaml? Is OCaml able to efficiently...
Froufrou asked 5/7, 2011 at 20:30

15

Solved

I want to create a list of integers from 1 to n. I can do this in Python using range(1, n+1), and in Haskell using: take n (iterate (1+) 1). What is the right OCaml idiom for this?
Chandless asked 28/10, 2008 at 16:6

2

Solved

I know of the OCaml debugging tool (first compile with ocamlc -g <file>, then run ocamldebug <output>) and also the function call tracing feature in the toplevel (both covered here). Ho...
Clayberg asked 3/12, 2020 at 20:48

2

So I'm writing a simple method that sums up the first 3 or less ints in a list but i'm confused about the match patterns. I currently have let sums l = match l with | [] -> 0 | (h1::h2::h3::_...
Tillett asked 20/2, 2016 at 3:13

4

How can I make a lazy list representing a sequence of doubling numbers? Example: 1 2 4 8 16 32
Guardhouse asked 27/10, 2009 at 16:17

2

Solved

in Toplevel, how to turn on the stack trace for exceptions? simple question, don't know how to ask more in details.
Gruelling asked 2/3, 2013 at 1:15

5

Solved

I can't use print_endline because it requires a string, and I don't (think) I have any way to convert my very simple user-defined datatypes to strings. How can I check the values of variables of th...
Katharinakatharine asked 22/9, 2011 at 17:11

3

I am using Ocaml of version 4. When I define interactively some type, the interpreter prints out string representation of the type immediately after that: # type foo = Yes | No;; <-- This is wh...
Trainee asked 12/1, 2013 at 7:33

1

Solved

How can I understand the type of Printf.printf? Printf.printf ;; - : ('a, out_channel, unit) format -> 'a = <fun> knowing that Printf.printf "%n" is a function of type int...
Keilakeily asked 1/4, 2023 at 15:58

2

Solved

In common lisp, we can use the remove function. It seems there is no such a method in OCaml ?
Stairwell asked 10/11, 2011 at 6:54

5

What is the right way to call an external command and collect its output in OCaml? In Python, I can do something like this: os.popen('cmd').read() How I can get all of an external program's out...
Hannis asked 6/2, 2010 at 22:20

5

Solved

I'm looking at the List documentation. It seems the library does not provide a sublist function. I'm trying to get list of elements from i to j. Now I have to write it as: let rec sublist list i ...
Avlona asked 25/4, 2010 at 22:31

19

Solved

I've come across the term 'Functor' a few times while reading various articles on functional programming, but the authors typically assume the reader already understands the term. Looking around on...
Deroo asked 8/1, 2010 at 21:26

5

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...
Justiciable asked 21/8, 2009 at 4:39

2

As the documentation on OCaml is sparse, i would appreciate if some one can explain the difference in different flavors of let usage. I tried looking into https://dev.realworldocaml.org/toc.html, b...
Michelle asked 8/1, 2023 at 23:38

2

Solved

I want to annotate a function from an external library as deprecated, to ensure it will not be use in my project. Let's assume the library offers the following module: module Lib : sig val safe_f...
Hysterectomize asked 2/2, 2018 at 9:29

6

Is there a standard sum type like Either but for 3 cases? Haskell has These but it's not quite that.
Fatuous asked 7/8, 2016 at 12:14

© 2022 - 2024 — McMap. All rights reserved.