2013-12-08 17:07:53 +01:00
|
|
|
open Http_client
|
|
|
|
open Str
|
|
|
|
|
2013-10-28 13:42:28 +01:00
|
|
|
(* Regexp required here *)
|
|
|
|
let is_youtube_url url =
|
2013-12-08 17:07:53 +01:00
|
|
|
let regexp = Str.regexp "http://www.youtube.com/.+" in
|
|
|
|
Str.string_match regexp url 0;;
|
2013-10-28 13:42:28 +01:00
|
|
|
|
|
|
|
(* Maybe have a list of functions and
|
|
|
|
* iter on all the items in the list *)
|
2013-10-25 14:21:05 +02:00
|
|
|
let evaluate str =
|
2013-10-28 13:42:28 +01:00
|
|
|
match str with
|
|
|
|
| str when is_youtube_url str -> "that's youtube"
|
|
|
|
| _ -> str;;
|
|
|
|
|
2013-10-25 14:21:05 +02:00
|
|
|
|
|
|
|
try
|
|
|
|
while true do
|
|
|
|
print_string "> ";
|
|
|
|
let line = read_line () in
|
|
|
|
let answer = evaluate line in
|
|
|
|
print_endline answer
|
2013-10-28 13:42:28 +01:00
|
|
|
done
|
2013-10-25 14:21:05 +02:00
|
|
|
with
|
|
|
|
End_of_file -> print_endline "Bye!";;
|