Skip to content

Instantly share code, notes, and snippets.

@Leonidas-from-XIV
Created April 21, 2015 15:15
Show Gist options
  • Save Leonidas-from-XIV/f6874230a0872a5760c3 to your computer and use it in GitHub Desktop.
Save Leonidas-from-XIV/f6874230a0872a5760c3 to your computer and use it in GitHub Desktop.
For caml in #ocaml
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