Questions tagged [ocaml]
OCaml is a strict statically-typed functional programming language, focusing on expressivity, correctness and efficiency.
51 questions
4 votes
1 answer
208 views
Weight balanced tree in OCaml
The objective was to create a weight-balanced binary search tree with a well-defined interface. Any critiques or suggestions for improvement are welcome. ...
2 votes
1 answer
79 views
ASCII grid creation
I've created an OCaml function which generates an ASCII grid with a specified cell size and number of cells per row. A grid with a cell size of 2 (chars) and a number of 3 cells per row looks as ...
2 votes
1 answer
94 views
Lazy evaluation vs strict one applied to fib
I have this OCaml problem: Recall the polymorphic type lazy seen in class, the function delay which transforms a ...
3 votes
1 answer
884 views
Functional Fibonacci in OCaml
I'm very new to OCaml, and as an exercise I decided to implement the nth Fibonacci algorithm (return a specific Fibonacci number, given an index) in different ways, using what I've learned so far. I ...
1 vote
0 answers
203 views
Longest Substring Without Repeating Characters in ReasonML/Ocaml
LeetCode Problems 3. Longest substring without repeating characters Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", ...
3 votes
1 answer
306 views
Scrolling text (marquee) in terminal
I wrote an OCaml program that displays a scrolling marquee in the terminal: Code: ...
1 vote
1 answer
1k views
OCaml backend for REST API and JSON data
I want to create a backend for a simple REST API in OCaml. For this I use the libs httpaf and yojson. I have something that works but I would like some reviews. Here is the structure of my little ...
2 votes
2 answers
176 views
Advent of Code 2018 Day 1 in OCaml: Find length of cycles when accumulating deltas
I just started Advent of Code 2018. This is exercise 2 of day 1, and I can't understand why my code is so slow (4 minutes 37 seconds, compared to 200ms for a friend who did it in Clojure with the same ...