From 6fc1084cf13ec0578f7774fd41aee2dd2ace1649 Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Sat, 19 Sep 2020 20:33:40 +0200 Subject: course: use a match/with instead of a if-chain in `location_and_summary' Signed-off-by: Alban Gruin --- src/course.ml | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src') 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 -- cgit v1.2.1