Go Fish/OCaml: Difference between revisions

m
Fixed syntax highlighting.
No edit summary
m (Fixed syntax highlighting.)
 
(3 intermediate revisions by 3 users not shown)
Line 1:
{{collection|Go Fish}}[[Category:OCaml]]
 
<langsyntaxhighlight lang="ocaml">type pip = Two | Three | Four | Five | Six | Seven | Eight | Nine | Ten |
Jack | Queen | King | Ace
let pips = [Two; Three; Four; Five; Six; Seven; Eight; Nine; Ten;
Line 38:
let pip_of_card (pip, _) = (pip)
 
let deck =
let deck = List.concat (List.map (fun pip -> List.map (fun suit -> (pip, suit)) suits) pips)
 
 
Line 146 ⟶ 147:
Printf.printf "choose from 1 to %d\n%!" n;
let get_int() =
try int_of_stringread_int(read_line())
with Failure "int_of_string" -> raise Exit
in
Line 314 ⟶ 315:
Printf.printf "player a has %d books\n" (player_a#books_length);
Printf.printf "player b has %d books\n" (player_b#books_length);
;;</langsyntaxhighlight>
9,476

edits