-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'resync-triangle' of github.com:marionebl/ocaml into res…
…ync-triangle
- Loading branch information
Showing
36 changed files
with
430 additions
and
290 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM ocaml/opam2:alpine-3.9-ocaml-4.07 | ||
|
||
RUN sudo apk add m4 linux-headers | ||
RUN opam install dune ocamlfind core ounit qcheck react ppx_deriving yojson ounit ocp-indent | ||
RUN opam install dune ocamlfind core ounit qcheck react ppx_deriving yojson ounit ocp-indent calendar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
open Base | ||
|
||
type nucleotide = A | C | G | T | ||
|
||
(** Compute the hamming distance between the two lists. *) | ||
val hamming_distance : nucleotide list -> nucleotide list -> int option | ||
val hamming_distance : nucleotide list -> nucleotide list -> (int, string) Result.t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
(executable | ||
(name test) | ||
(libraries core_kernel oUnit)) | ||
(libraries base calendar oUnit)) | ||
|
||
(alias | ||
(name runtest) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
open Base | ||
open CalendarLib | ||
|
||
type schedule = First | Second | Third | Fourth | Teenth | Last | ||
|
||
type weekday = Monday | Tuesday | Wednesday | Thursday | ||
| Friday | Saturday | Sunday | ||
|
||
type date = (int * int * int) | ||
|
||
let diff_days (d1: weekday) (d2: weekday): int = | ||
let weekday_to_int = function | ||
| Monday -> 0 | ||
| Tuesday -> 1 | ||
| Wednesday -> 2 | ||
| Thursday -> 3 | ||
| Friday -> 4 | ||
| Saturday -> 5 | ||
| Sunday -> 6 in | ||
(weekday_to_int d1 - weekday_to_int d2) % 7 | ||
|
||
let day_of_week (d: Date.t): weekday = | ||
match Date.day_of_week d with | ||
| Sun -> Sunday | ||
| Mon -> Monday | ||
| Tue -> Tuesday | ||
| Wed -> Wednesday | ||
| Thu -> Thursday | ||
| Fri -> Friday | ||
| Sat -> Saturday | ||
|
||
let schedule_to_int = function | ||
| First -> 0 | ||
| Second -> 1 | ||
| Third -> 2 | ||
| Fourth -> 3 | ||
| Teenth -> 4 | ||
| Last -> 5 | ||
|
||
let add_days base days = | ||
Date.Period.day days |> Date.add base | ||
|
||
let meetup_day schedule weekday ~year ~month = | ||
let base = Date.make year month 1 in | ||
let calc_offset start = start + diff_days weekday (add_days base start |> day_of_week) in | ||
let day = calc_offset @@ match schedule with | ||
| Teenth -> 12 | ||
| Last -> 21 + max 0 (Date.days_in_month base - 28) | ||
| _ -> 7 * schedule_to_int schedule in | ||
let core_date = add_days base day | ||
in (Date.year core_date, | ||
Date.month core_date |> Date.int_of_month, | ||
Date.day_of_month core_date) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
default: clean test | ||
|
||
test: | ||
jbuilder runtest | ||
dune runtest | ||
|
||
clean: | ||
jbuilder clean | ||
dune clean | ||
|
||
.PHONY: clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
(executable | ||
(name test) | ||
(libraries base oUnit) | ||
(preprocess | ||
(pps ppx_deriving.eq ppx_deriving.show))) | ||
|
||
(alias | ||
(name runtest) | ||
(deps | ||
(:< test.exe)) | ||
(action | ||
(run %{<}))) | ||
|
||
(env | ||
(dev | ||
(flags (:standard -warn-error -A)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
(lang dune 1.0) |
Oops, something went wrong.