-
Notifications
You must be signed in to change notification settings - Fork 304
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* "Pratice-009-done" * "Done" * Update impl.ml * Update run.ml * Update impl.ml * Update ex.ml * Update dune * Do not touch irrelevant file * "Update -lines added" * "Update -Extra lines deleted" * "Update -Extra lines deleted" * Update ex.ml
- Loading branch information
Showing
9 changed files
with
40 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
let pack list = | ||
let rec aux current acc = function | ||
| [] -> [] (* Can only be reached if original list is empty *) | ||
| [x] -> (x :: current) :: acc | ||
| a :: (b :: _ as t) -> | ||
if a = b then aux (a :: current) acc t | ||
else aux [] ((a :: current) :: acc) t in | ||
List.rev (aux [] [] list);; |
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,2 @@ | ||
(include_subdirs no) | ||
(test (name run) (libraries ounit2 ex)) |
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,3 @@ | ||
module Test = Ex.Make(Ex.Answer) | ||
|
||
let () = OUnit2.run_test_tt_main Test.v |
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,2 @@ | ||
(include_subdirs qualified) | ||
(library (name ex) (libraries ounit2)) |
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 3.7) |
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,18 @@ | ||
open OUnit2 | ||
|
||
module type Testable = sig | ||
val pack : 'a list -> 'a list list | ||
end | ||
|
||
module Make(Tested: Testable) : sig val v : test end = struct | ||
let v = "pack" >::: [ | ||
"example" >:: (fun _ -> | ||
assert_equal | ||
[["a"; "a"; "a"; "a"]; ["b"]; ["c"; "c"]; ["a"; "a"]; ["d"; "d"]; | ||
["e"; "e"; "e"; "e"]] | ||
(Tested.pack ["a"; "a"; "a"; "a"; "b"; "c"; "c"; "a"; "a"; "d"; "d"; "e"; "e"; "e"; "e"])) | ||
] | ||
end | ||
|
||
module Work : Testable = Work.Impl | ||
module Answer : Testable = Answer.Impl |
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 @@ | ||
let pack _ = failwith "Not yet implemented" |
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,2 @@ | ||
(include_subdirs no) | ||
(test (name run) (libraries ounit2 ex)) |
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,3 @@ | ||
module Test = Ex.Make(Ex.Work) | ||
|
||
let () = OUnit2.run_test_tt_main Test.v |