forked from ocaml/ocaml
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@562 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
- Loading branch information
1 parent
e49ed7c
commit 1a2688c
Showing
1 changed file
with
19 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
let rec tak (x, y, z) = | ||
if x > y then tak(tak (x-1, y, z), tak (y-1, z, x), tak (z-1, x, y)) | ||
else z | ||
|
||
let break_handler _ = | ||
print_string "Thank you for pressing ctrl-C."; print_newline(); | ||
print_string "Allocating a bit..."; flush stdout; | ||
tak(18,12,6); print_string "done."; print_newline() | ||
|
||
let _ = | ||
Sys.signal Sys.sigint (Sys.Signal_handle break_handler); | ||
print_string "Computing like crazy..."; print_newline(); | ||
for i = 1 to 100 do tak(18,12,6) done; | ||
print_string "Reading on input..."; print_newline(); | ||
for i = 1 to 5 do | ||
let s = read_line () in | ||
print_string ">> "; print_string s; print_newline() | ||
done; | ||
exit 0 |