From 642c6aa94a15b6414c7ca5aa4c7970cae2f4a0e5 Mon Sep 17 00:00:00 2001 From: Fabien Freling Date: Mon, 28 Oct 2013 13:42:28 +0100 Subject: [PATCH] Update OCaml code with pattern guards. Now the missing piece for recognizing urls is regexp support. --- ocaml/main.ml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ocaml/main.ml b/ocaml/main.ml index 69c9b71..9694831 100644 --- a/ocaml/main.ml +++ b/ocaml/main.ml @@ -1,5 +1,16 @@ +(* Regexp required here *) +let is_youtube_url url = + match url with + | "http://www.youtube.com/" -> true + | _ -> false;; + +(* Maybe have a list of functions and + * iter on all the items in the list *) let evaluate str = - str;; + match str with + | str when is_youtube_url str -> "that's youtube" + | _ -> str;; + try while true do @@ -7,6 +18,6 @@ try let line = read_line () in let answer = evaluate line in print_endline answer - done; + done with End_of_file -> print_endline "Bye!";;