Update OCaml code with pattern guards.

Now the missing piece for recognizing urls is
regexp support.
This commit is contained in:
Fabien Freling 2013-10-28 13:42:28 +01:00
parent 1fd5486328
commit 642c6aa94a

View file

@ -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 = let evaluate str =
str;; match str with
| str when is_youtube_url str -> "that's youtube"
| _ -> str;;
try try
while true do while true do
@ -7,6 +18,6 @@ try
let line = read_line () in let line = read_line () in
let answer = evaluate line in let answer = evaluate line in
print_endline answer print_endline answer
done; done
with with
End_of_file -> print_endline "Bye!";; End_of_file -> print_endline "Bye!";;