chess960 in OCaml — Validating the King

let valid_king pos =
  filter (fun p -> p = R || p = K) pos = [R; K; R]
# let valid_king pos =
  filter (fun p -> p = R || p = K) pos = [R; K; R];;
  val valid_king : piece list -> bool = <fun>
# map (fun p -> p = R || p = K) [R;N;B;Q;K;B;N;R];;
- : bool list = [true; false; false; false; true; false; false; true]
# filter (fun p -> p = R || p = K) [R;N;B;Q;K;B;N;R];;
- : piece list = [R; K; R]
# filter (fun p -> p = R || p = K) [R;K;N;B;Q;B;N;R];;
- : piece list = [R; K; R]
# filter (fun p -> p = R || p = K) [R;N;B;Q;B;N;R;K];;
- : piece list = [R; R; K]
# 
# valid_king [R;N;B;Q;K;B;N;R];;
- : bool = true
# valid_king [R;K;N;B;Q;B;N;R];;
- : bool = true
# valid_king [R;N;B;Q;B;N;R;K];;
- : bool = false
#