aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlban Gruin2020-09-19 20:33:40 +0200
committerAlban Gruin2020-09-19 20:33:40 +0200
commit6fc1084cf13ec0578f7774fd41aee2dd2ace1649 (patch)
tree405518795d8fa3d2e12ee103eceb56196a468825
parent36c9cd7d082bb2077a910269702a13784ef10fbb (diff)
course: use a match/with instead of a if-chain in `location_and_summary'
Signed-off-by: Alban Gruin <alban at pa1ch dot fr>
-rw-r--r--src/course.ml15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/course.ml b/src/course.ml
index 461c99c..6109a3e 100644
--- a/src/course.ml
+++ b/src/course.ml
@@ -59,15 +59,12 @@ let location_and_summary str category =
let parts = Astring.String.cuts ~empty:false ~sep str in
let _, location, summary =
List.fold_right
- (fun str (has_groups, location, summary) ->
- if not has_groups then
- check_groups str, "", ""
- else if location = "" then
- true, replace_entities str, ""
- else if summary = "" then
- true, replace_entities str, location
- else
- true, location, summary) parts (false, "", "") in
+ (fun str -> function
+ | false, _, _ -> check_groups str, "", ""
+ | true, "", _ -> true, replace_entities str, ""
+ | true, summary, "" -> true, replace_entities str, summary
+ | true, location, summary -> true, location, summary)
+ parts (false, "", "") in
if summary = "" then
location, category
else