spacepaste

  1.  
  2. let median l =
  3. let rec aux = function
  4. | e :: _, ([_] | [_; _]) -> e
  5. | _ :: tl1, _ :: _ :: tl2 -> aux (tl1, tl2)
  6. | _, _ -> invalid_arg "median"
  7. in
  8. aux (l, l)
  9.