ocaml

IDE for OCaml language

。_饼干妹妹 提交于 2019-12-03 08:19:38
问题 Is there any trusted OCaml IDE other than Camelia ? I would prefer an eclipse based IDE if existed. 回答1: Editors • Emacs ◦ ocaml-mode from the standard distribution ◦ alternative tuareg-mode https://forge.ocamlcore.org/projects/tuareg/ − cheat-sheet: http://www.ocamlpro.com/files/tuareg-mode.pdf ◦ camldebug intergration with debugger ◦ type feedback with C-c C-t key shortcut, needs .annot files • Vim ◦ OMLet plugin http://www.lix.polytechnique.fr/~dbaelde/productions/omlet.html ◦ For type

About the pattern matching algorithm in OCaml

狂风中的少年 提交于 2019-12-03 07:46:46
I am writing a compiler for a functional language I designed with OCaml. I want my little language to have the feature of pattern matching, however, I got stuck in coming up with an algorithm to implement it. It seems really complicated as I dig into the problem. I can't find much useful information about the corresponding algorithm with google. I will be appreciated if someone can give me some hint or point me to the resources. Or are there any tricks to take advantage of OCaml's power in pattern matching to solve this problem so that I don't need to implement it? Thanks! gsg There's a few

What is the OCaml idiom equivalent to Python's range function?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-03 05:29:22
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? There is no idiom that I know of, but here is a fairly natural definition using an infix operator: # let (--) i j = let rec aux n acc = if n < i then acc else aux (n-1) (n :: acc) in aux j [] ;; val ( -- ) : int -> int -> int list = <fun> # 1--2;; - : int list = [1; 2] # 1--5;; - : int list = [1; 2; 3; 4; 5] # 5--10;; - : int list = [5; 6; 7; 8; 9; 10] Alternatively, the comprehensions syntax extension (which gives

Is it possible to use arrow keys in OCaml interpreter?

泄露秘密 提交于 2019-12-03 04:48:07
Everytime I use these keys in the interpreter I keep getting symbols like this appearing: [[D^[[C I'm using Linux Mint 12 in ZSH, however I'm getting the same result in Ubuntu with bash. Also, same thing in ssh. The stock OCaml toplevel doesn't have line editing built in. I use rlwrap : $ cat bin/ocaml #!/bin/sh exec rlwrap /usr/local/bin/ocaml "$@" Using the toplevel without something like this is quite painful, in my opinion! Other possibilities are to run the toplevel under emacs (a popular choice, I think), or to use utop . I haven't used utop, but it sounds cool. Another option is to use:

List of Functional code snippets for Procedural Programmers? [closed]

一世执手 提交于 2019-12-03 04:21:11
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . Sometimes I still get stuck trying to translate procedural code into functional code. Is there a list of functional idioms/snippets

Functional Breadth First Search

我只是一个虾纸丫 提交于 2019-12-03 04:16:26
问题 Functional depth first search is lovely in directed acyclic graphs. In graphs with cycles however, how do we avoid infinite recursion? In a procedural language I would mark nodes as I hit them, but let's say I can't do that. A list of visited nodes is possible, but will be slow because using one will result in a linear search of that list before recurring. A better data structure than a list here would obviously help, but that's not the aim of the game, because I'm coding in ML - lists are

Recommended reading on general debugging techinques

只谈情不闲聊 提交于 2019-12-03 03:54:18
What reading would you recommend on general debugging techniques? I am more interested in principles and best practices than in specific platform solutions. For the record I mainly work with .NET (F#, C#), and dabble in Haskell and Ocaml. One of these Friday evenings we talked about debugging with my colleague on our walk home. I was surprised to learn that one can view and modify the state of live objects from the VisualStudio debugger. He also mentioned that another developer he knew, a "Java guru," had once shown him some debugging magic and given an article or booklet on debugging, which

What is the state of OCaml's parallelization abilities?

不羁的心 提交于 2019-12-03 03:31:01
问题 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 use more than 1 CPU? Most of what I have read on the subject was written in 2002-2006, and I haven't seen anything more recent. Thanks! 回答1: This 2009 issue of the Caml weekly news ("CWN", a digest of interesting messages from the caml list) shows that: the official party line on threads and Ocaml

How to make a multi-level module hierarchy with (or without) Oasis

匆匆过客 提交于 2019-12-03 03:20:27
Suppose I have a set of modules each of which being rather "bushy" with submodules. M1.X M2.X M3.X M1.Y M2.Y M3.Y M1.Z M2.Z M3.Z M1.W M2.W M3.W M1.Q M2.Q M3.Q M1.P M2.P M3.P Moreover, I'd like each of these bushes to sit under one master module. Home.M1 Home.M2 Home.M3 Now, it's easy to structure the project directory for each of M1 , M2 , and M3 using Oasis' Pack: option. In particular, what I like and am trying to solve for is (a) the ability to lay out my files in the standard .ml / .mli format and (b) having ocamldoc produce properly linked documentation. But since I'd like to distribute

Lazy “n choose k” in OCaml

北城余情 提交于 2019-12-03 03:10:52
As part of a bigger problem of enumerating a set, I need to write an OCaml function 'choose' which takes a list and outputs as the list of all possible sequences of size k made up of elements of that list (without repeating sequences which can be obtained from each other by permutation). The order they are put in the end list is not relevant. For example, choose 2 [1;2;3;4] = [[1;2];[1;3];[1;4];[2;3];[2;4];[3;4]] Any ideas? I would like to have the whole thing to be lazy, outputting a lazy list, but if you have a strict solution, that'll be very useful too. Here is a strict and suboptimal