chess960 in OCaml — Validating the Bishops

let sublist_between a b =
  (takewhile ((<>) b)) & tl & (dropwhile ((<>) a))
# let sublist_between a b = (takewhile ((<>) b)) & tl & (dropwhile ((<>) a));;
val sublist_between : 'a -> 'a -> 'a list -> 'a list = <fun>
# sublist_between B B [R;N;B;Q;K;B;N;R];;
- : piece list = [Q; K]
# (dropwhile ((<>) B)) [R;N;B;Q;K;B;N;R];;
- : piece list = [B; Q; K; B; N; R]
# (tl & (dropwhile ((<>) B))) [R;N;B;Q;K;B;N;R];;
- : piece list = [Q; K; B; N; R]
# ((takewhile ((<>) B)) & tl & (dropwhile ((<>) B))) [R;N;B;Q;K;B;N;R];;
- : piece list = [Q; K]
# 
let valid_bishops pos =
  length (sublist_between B B pos) mod 2 = 0
# let valid_bishops pos =
  length (sublist_between B B pos) mod 2 = 0;;
  val valid_bishops : piece list -> bool = <fun>
# valid_bishops [R;N;B;Q;K;B;N;R];;
- : bool = true
# valid_bishops [R;N;B;B;Q;K;N;R];;
- : bool = true
# valid_bishops [R;N;B;Q;B;K;N;R];;
- : bool = false
#