cheesebot/ocaml/main.ml
Fabien Freling 642c6aa94a Update OCaml code with pattern guards.
Now the missing piece for recognizing urls is
regexp support.
2013-10-28 13:42:28 +01:00

24 lines
493 B
OCaml

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