-
-
Save ThePhD/414c828773dc292bec92228ba5e6d21d to your computer and use it in GitHub Desktop.
:I
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
let list_print (l: string list) : unit = | |
(* *) | |
List.iter ( print_endline ) l;; | |
let rec oxford (l: string list) : string = | |
(* match the value of list, or replace with foldL | |
somehow until it works? *) | |
match List.length l with | |
| [] -> "" | |
| h :: [] -> h | |
| h :: t when List.length t = 1 -> h ^ " and " ^ oxford t | |
| h :: t when List.length t <> 1 -> h ^ ", " ^ oxford t | |
| _ -> "?" (* wat *) | |
oxford [];; | |
oxford ["a"];; | |
oxford ["a"; "b"];; | |
oxford ["a"; "b"; "c"];; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment