Quantcast
Channel: Active questions tagged ocaml - Stack Overflow
Browsing all 518 articles
Browse latest View live
↧

OCaml: Simplest way to merge 2 lists

Example: merge [o;d] [l;n] returns [o;l;d;n]let rec merge (x::t1) (y::t2) = x::y::merge t1 t2;;this gives Exception: Match_failure ("//toplevel//", 1, 14)after merge [o;d] [l;n]

View Article


Extracting elements from 2d list

I have the following 2d list [ [a1 ; a2 ; a3 ; a4] ; [b1 ; b2 ; b3 ; b4] ; [c1 ; c2 ; c3 ; c4] ]and I have an input function F.I have the following problem : Given a 2d list m and a function f, compute...

View Article


How do I read in lines from a text file in OCaml?

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)

View Article

How to check the version of GMP, MPFR and CamlIDL?

My question is simple... How could I check the version of GMP installed on my machine? What about MPFR? And What about CamlIDL?Thank you very much

View Article

Image may be NSFW.
Clik here to view.

Find a path in a graph from source to destination using BFS

I have been through an issue while I was implementing a function that give me a path from a source node to a destination node using BFS. I'm using BFS to find a path because I want my path to have...

View Article


Can't compile Hello World in F*

Both OCaml and F* have been successfully installed. The only thing resembling a Hello World example I was able to find was:module Helloopen FStar.IOlet main = print_string "Hello F*!\n"from its GitHub...

View Article

A typical bracket balanced problem in ocaml

I'm trying to create a function which returns a boolean value to see if the string is balanced. But the result is just not what I expect. Can someone point out what I did wrong?For example:false =...

View Article

Ocaml count trie elements

I'm trying to find how many characters i have in my Trie.This is my Trie type.type 'a t = Node of 'a list * ('a arc list) and 'a arc = char * 'a tThis is my implementation that is not exhaustive:let...

View Article


cannot install OCaml on windows: permission error

I am trying to follow this guide to install OCaml on windows. All I've done is download the latest installer from here, but when I try to run it I get:FATAL [ebe9e0f2]. rename...

View Article


How to add a library dependency in a dune project that manages the .opam file...

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...

View Article

Stdio.printf giving type error while Printf.printf does not

A 'small' ocaml printf issue.There is a printf in module Printf that works in utop and even ocaml (interpreter) and with ocamlc (compiled)There is printf in module Stdio. that only works in utop and...

View Article

opam upgrade to most recent version failure

On an Ubuntu 64-bit version 22.04 device, I have opam and ocaml installed, with ocaml having version 4.08.0 and I would like to upgrade it to 5.1.0 to use the Effects package. However, running opam...

View Article

Image may be NSFW.
Clik here to view.

How to fix error message when adding ocaml binaries directory to eclipse path?

I've installed OcaIDE from the following link, http://www.algo-prog.info/ocaide and added it to eclipse. I also installed Ocaml64 from the following link,...

View Article


Camlp5: Converting a polymorphic type definition to strict syntax

I have some old code using Camlp5. I have always used the version of Camlp5 shipped with Debian. Now this version 8.00.04 in strict mode. My old code does not compile any more. The problem seems to be...

View Article

OCaml: How to use a string as a module name

I'm writing a piece of code where I have multiple modules, all with a value called "foo", for instance, and I want to be able to choose which module I reference based on the value of a string. For...

View Article


How to dynamically access a module by a string [closed]

I'm writing a program where I want to be able to use a command-line argument as the name of a module to access. Using this code as an example:module Foo = struct let run () = print_endline "running...

View Article

Is it possible to compile OCaml codes using Core without corebuild?

I'm using Ubuntu 18.04. I have OCaml 4.05 installed (via apt-get) as well as utop and Core (via opam). And this is the content of my ~/.ocamlinit:(* Added by OPAM. *)let () = try Topdirs.dir_directory...

View Article


Contribution towards making OCaml more Easy

I've just delved into the world of OCaml as part of my degree and I found it fascinating exploring functional programming.So just as a small side project I wanted to make a repo that would include...

View Article

How to make modules/Libraries in OCaml? [closed]

It'd be great if someone could explain how I could make modules out of my OCaml files for people to use.I have tried using GPT to sort of convert it into a module, Still can't get it working, could...

View Article

Image may be NSFW.
Clik here to view.

OCaml Syntax error with if-else block without any information

I currently am faced with a problem with if-else block with end keyword. Here is my problem method. And here is a link to my full project. let parkVehicle () = try print_string "Please enter the...

View Article
Browsing all 518 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>