package cll
All checked builds passInstall
dune-project
Dependency
Authors
Maintainers
Sources
md5=534e5defb87dfefab80ad58477ee860b
sha512=3324a8b80a9e642fc729d439fb9ecf9a9d40ea465f53b50f2ad6ac62bddc1a11031ab094e0b1223d0200c982b05604d4e3603e754bf1be2583bc5ba230a8f700
Description
A mutable circular doubly linked list designed for O(1) insertion and removal, O(n) traversal, and close to O(1) search using a backing hashtable.
README
ocaml-cll
OCaml circular linked list library
Installation
$ opam install cllUsage
To be run in the ocaml toplevel
let cll = Cll.init [ 1; 2; 3; 4; 5; 6 ];;
Cll.head cll;;
(* int option = Some 1 *)
Cll.length cll;;
(* int = 6 *)
Cll.next cll;;
Cll.head cll;;
(* int option = Some 2 *)
Cll.prev cll;;
Cll.prev cll;;
Cll.head cll;;
(* int option = Some 6 *)
Cll.add cll 7;;
Cll.head cll;;
(* int option = Some 7 *)
Cll.pop cll;;
(* int option = Some 7 *)
Cll.head cll;;
(* int option = Some 1 *)
Cll.find cll 4;;
(* bool = true *)
Cll.head cll;;
(* int option = Some 4 *)
Cll.iter cll (fun x -> Printf.printf "%i\n")
(*
4
5
6
1
2
3
*)
Cll.to_list cll;;
(* int list = [4; 5; 6; 1; 2; 3] *)Development requirements
- OCaml
- Opam
- Dune
$ ocaml --version
The OCaml toplevel, version 5.1.0
$ opam --version
2.1.5
$ dune --version
3.11.0Development setup
Install dependencies
opam install . --deps-only --with-test -yBuild code
dune buildTesting
Run unit tests
$ dune test
.................
Ran: 17 tests in: 0.11 seconds.
OKCheck code coverage
dune test --instrument-with bisect_ppx --force
# show coverage summary
bisect-ppx-report summary
# create html coverage report
bisect-ppx-report html
open _coverage/index.htmlRunning examples
There aren't many uses I'm aware of for a circular linked list, but I have found two programming puzzles where it's been handy.
Prerequisites
From the project's root directory:
# install utop
$ opam install utopCodewars: Josephus problem
# run the josphus_problem.ml toplevel script
$ dune utop . -- examples/josephus_problem.ml
4Advent of Code 2020 day 23: Crab Cups
By default only part one of this puzzle will run, as part two takes about 40 seconds on my laptop when running with utop.
To enable part two, uncomment the last three lines in examples/crab_cups.ml.
# run part one of the crab cups toplevel script
$ dune utop . -- examples/crab_cups.ml
part one: 67384529
Dev Dependencies (3)
-
odoc
with-doc -
bisect_ppx
with-test -
ounit2
with-test
Used by
None
Conflicts
None
Build status
Results of building cll with each compiler on check.ci.ocaml.org, run of against opam-repository 7cdc698. All results for this package.
Each result links to its build log. To keep crawlers from overloading the site, build logs require a GitHub sign-in (see ocurrent/opam-health-check). On your first log, GitHub asks you to “Authorize opam-health-check”, the OCurrent app that runs these checks; it sees only your public profile, not your repositories. The sign-in lasts 30 days.
| Version | OCaml 4.11 | OCaml 4.14 | OCaml 5.2 | OCaml 5.4 | OCaml 5.5 |
|---|---|---|---|---|---|
| 0.2.0 (this version) | good | good | good | good | good |
- good Package successfully built
- partial One of the dependencies failed to build
- bad Package failed to build
- n/a Package is not available in this environment
- internal Internal failure