Created
April 21, 2015 15:15
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