Created
April 21, 2015 15:15
-
-
Save Leonidas-from-XIV/f6874230a0872a5760c3 to your computer and use it in GitHub Desktop.
For caml in #ocaml
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
open Core_kernel.Std | |
type colour = Red | Green | Magenta | Yellow | Blue | Black | White | Cyan | |
let shuffle l = | |
List.map ~f:(fun c -> (Random.bits (), c)) l | |
|> List.sort ~cmp:compare | |
|> List.map ~f:snd | |
let all = [Red; Green; Magenta; Yellow; Blue; Black; White; Cyan] | |
let random_four () = | |
all | |
|> shuffle | |
|> (Fn.flip List.take) 4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment