Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
ocaml-edt
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Emmanuel Coquery
ocaml-edt
Commits
7f4bb051
Commit
7f4bb051
authored
8 months ago
by
Emmanuel Coquery
Browse files
Options
Downloads
Patches
Plain Diff
Backport of core representation from grid
parent
cf4322ea
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
dune-project
+1
-1
1 addition, 1 deletion
dune-project
lib/Timetable.ml
+99
-0
99 additions, 0 deletions
lib/Timetable.ml
lib/dune
+2
-1
2 additions, 1 deletion
lib/dune
ocaml_edt.opam
+1
-0
1 addition, 0 deletions
ocaml_edt.opam
with
103 additions
and
2 deletions
dune-project
+
1
−
1
View file @
7f4bb051
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
(name ocaml_edt)
(name ocaml_edt)
(synopsis "Generates timetables for course planification")
(synopsis "Generates timetables for course planification")
(description "Program and library to generate a timetable for a course or a set of courses, outputs in HTML format among others")
(description "Program and library to generate a timetable for a course or a set of courses, outputs in HTML format among others")
(depends ocaml dune cmdliner)
(depends ocaml dune cmdliner
calendar
)
(tags
(tags
(topics "timetable")))
(topics "timetable")))
...
...
This diff is collapsed.
Click to expand it.
lib/Timetable.ml
0 → 100644
+
99
−
0
View file @
7f4bb051
let
lex
access
cmp
fn
v1
v2
=
let
v
=
fn
v1
v2
in
if
v
!=
0
then
v
else
cmp
(
access
v1
)
(
access
v2
)
let
lex_r
access
cmp
fn
v1
v2
=
let
v
=
cmp
(
access
v1
)
(
access
v2
)
in
if
v
!=
0
then
v
else
fn
v1
v2
let
eq
_
_
=
0
let
rec
gcd
n
m
=
if
m
=
0
then
n
else
gcd
m
(
n
mod
m
)
type
date
=
CalendarLib
.
Date
.
t
let
as_iso
(
d
:
date
)
:
string
=
CalendarLib
.
Printer
.
Date
.
sprint
"%F"
d
type
'
a
cell
=
{
rowspan
:
int
;
colspan
:
int
;
content
:
'
a
}
type
'
a
line
=
{
headers
:
string
cell
list
;
cells
:
'
a
cell
list
}
type
'
a
table
=
{
columns_headers
:
string
cell
list
list
;
lines
:
'
a
line
list
;
}
module
type
ResourcesT
=
sig
type
t
val
conflicts
:
t
->
t
->
bool
val
compare
:
t
->
t
->
int
end
module
Make
(
R
:
ResourcesT
)
=
struct
module
D
=
CalendarLib
.
Date
type
heure
=
int
let
heure
(
h
:
int
)
(
m
:
int
)
:
heure
=
(
h
*
60
)
+
m
type
creneau
=
{
resources
:
R
.
t
;
date
:
date
;
start
:
heure
;
duration
:
int
}
let
compare
=
eq
|>
lex
(
fun
c
->
c
.
date
)
D
.
compare
|>
lex
(
fun
c
->
c
.
start
)
(
-
)
|>
lex
(
fun
c
->
c
.
duration
)
(
-
)
|>
lex
(
fun
c
->
c
.
resources
)
R
.
compare
let
inside
h
h'
d
=
h'
<=
h
&&
h
<=
h'
+
d
let
intersect
c1
c2
=
c1
.
date
=
c2
.
date
&&
(
inside
c1
.
start
c2
.
start
c2
.
duration
||
inside
c2
.
start
c1
.
start
c1
.
duration
)
let
conflict
c1
c2
=
intersect
c1
c2
&&
R
.
conflicts
c1
.
resources
c2
.
resources
let
date
=
D
.
make
let
week_of_date
d
:
date
=
let
day
=
D
.
day_of_week
d
in
let
offset
=
1
-
D
.
int_of_day
day
in
D
.
add
d
(
D
.
Period
.
day
offset
)
exception
Conflit
of
(
creneau
*
creneau
)
let
rec
supprime_conflits
raise_exc
c
l
=
match
l
with
|
[]
->
l
|
c'
::
rest
->
if
conflict
c
c'
then
if
raise_exc
then
raise
(
Conflit
(
c
,
c'
))
else
supprime_conflits
raise_exc
c
rest
else
let
l_s
=
supprime_conflits
raise_exc
c
rest
in
if
l_s
==
rest
then
l
else
l_s
let
rec
place
(
raise_exc
:
bool
)
(
c
:
creneau
)
(
l
:
creneau
list
)
:
creneau
list
=
match
l
with
|
[]
->
[
c
]
|
c'
::
rest
when
conflict
c
c'
->
place
raise_exc
c
rest
|
c'
::
rest
when
compare
c'
c
<=
0
->
c'
::
place
raise_exc
c
rest
|
c'
::
rest
->
c
::
c'
::
supprime_conflits
raise_exc
c
rest
let
groupby
gv
cmp
cmp2
l
=
let
l
=
List
.
map
(
fun
c
->
(
gv
c
,
c
))
l
in
let
cmp_p
=
eq
|>
lex
fst
cmp
|>
lex
snd
cmp2
in
let
l
=
List
.
sort
cmp_p
l
in
let
rec
aux
=
function
|
[]
->
[]
|
(
v
,
c
)
::
rest
->
(
match
aux
rest
with
|
[]
->
[
(
v
,
[
c
])
]
|
(
v'
,
cs'
)
::
rest'
->
if
v
=
v'
then
(
v'
,
c
::
cs'
)
::
rest'
else
(
v
,
[
c
])
::
(
v'
,
cs'
)
::
rest'
)
in
aux
l
let
by_week
l
=
groupby
(
fun
c
->
week_of_date
c
.
date
)
D
.
compare
compare
l
end
This diff is collapsed.
Click to expand it.
lib/dune
+
2
−
1
View file @
7f4bb051
(library
(library
(name ocaml_edt))
(name ocaml_edt)
(libraries calendar))
This diff is collapsed.
Click to expand it.
ocaml_edt.opam
+
1
−
0
View file @
7f4bb051
...
@@ -14,6 +14,7 @@ depends: [
...
@@ -14,6 +14,7 @@ depends: [
"ocaml"
"ocaml"
"dune" {>= "3.16"}
"dune" {>= "3.16"}
"cmdliner"
"cmdliner"
"calendar"
"odoc" {with-doc}
"odoc" {with-doc}
]
]
build: [
build: [
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment