commit 5e8eee3
Artur Manuel
·
2025-07-07 14:02:50 +0000 UTC
parent 3fbcaa9
feat(ocaml): add ocaml
9 files changed,
+115,
-0
+37,
-0
1@@ -0,0 +1,37 @@
2+*.annot
3+*.cmo
4+*.cma
5+*.cmi
6+*.a
7+*.o
8+*.cmx
9+*.cmxs
10+*.cmxa
11+
12+# Files containing detailed information about the compilation (generated
13+# by `ocamlc`/`ocamlopt` when invoked using the option `-bin-annot`).
14+# These files are typically useful for code inspection tools
15+# (e.g. Merlin).
16+*.cmt
17+*.cmti
18+
19+# ocamlbuild and Dune default working directory
20+_build/
21+
22+# ocamlbuild targets
23+*.byte
24+*.native
25+
26+# oasis generated files
27+setup.data
28+setup.log
29+
30+# Merlin configuring file for Vim and Emacs
31+.merlin
32+
33+# Dune generated files
34+*.install
35+
36+# Local OPAM switch
37+_opam/
38+
+4,
-0
1@@ -0,0 +1,4 @@
2+(executable
3+ (public_name rosetta_collatz)
4+ (name main)
5+ (libraries rosetta_collatz))
+5,
-0
1@@ -0,0 +1,5 @@
2+open Rosetta_collatz
3+
4+let () =
5+ let sequence = List.init 10000 (fun a -> Collatz.collatzSequence (a + 1))
6+ in print_endline (String.concat "\n" sequence)
+24,
-0
1@@ -0,0 +1,24 @@
2+(lang dune 3.7)
3+
4+(name rosetta_collatz)
5+
6+(generate_opam_files true)
7+
8+(source
9+ (sourcehut "amadaluzia/rosetta-collatz"))
10+
11+(authors "Artur Manuel")
12+
13+(maintainers "Artur Manuel")
14+
15+(license "2-BSD-Clause")
16+
17+(package
18+ (name rosetta_collatz)
19+ (synopsis "Rosetta code project for the Collatz conjecture")
20+ (description "Rosetta code project for the Collatz conjecture")
21+ (depends ocaml dune)
22+ (tags
23+ (rosetta-code collatz)))
24+
25+; See the complete stanza docs at https://dune.readthedocs.io/en/stable/dune-files.html#dune-project
+12,
-0
1@@ -0,0 +1,12 @@
2+let collatz (a : int) : int =
3+ if a mod 2 == 0
4+ then a / 2
5+ else 3 * a + 1
6+
7+let rec collatzSequence' (a : int) : string =
8+ if a == 1
9+ then "1"
10+ else (string_of_int a) ^ ", " ^ collatzSequence' (collatz a)
11+
12+let collatzSequence (a : int) : string =
13+ Printf.sprintf "%d: %s" a (collatzSequence' a)
+2,
-0
1@@ -0,0 +1,2 @@
2+(library
3+ (name rosetta_collatz))
+29,
-0
1@@ -0,0 +1,29 @@
2+# This file is generated by dune, edit dune-project instead
3+opam-version: "2.0"
4+synopsis: "Rosetta code project for the Collatz conjecture"
5+description: "Rosetta code project for the Collatz conjecture"
6+maintainer: ["Artur Manuel"]
7+authors: ["Artur Manuel"]
8+license: "2-BSD-Clause"
9+homepage: "https://sr.ht/~amadaluzia/rosetta-collatz"
10+bug-reports: "https://todo.sr.ht/~amadaluzia/rosetta-collatz"
11+depends: [
12+ "ocaml"
13+ "dune" {>= "3.7"}
14+ "odoc" {with-doc}
15+]
16+build: [
17+ ["dune" "subst"] {dev}
18+ [
19+ "dune"
20+ "build"
21+ "-p"
22+ name
23+ "-j"
24+ jobs
25+ "@install"
26+ "@runtest" {with-test}
27+ "@doc" {with-doc}
28+ ]
29+]
30+dev-repo: "git+https://git.sr.ht/~amadaluzia/rosetta-collatz"
+2,
-0
1@@ -0,0 +1,2 @@
2+(test
3+ (name rosetta_collatz))
+0,
-0