let partition pred xs =
  let yes = ref [] in
  let no = ref [] in
  List.iter (fun x ->
    if pred x then yes := x :: !yes
    else no := x :: !no
  ) xs;
  (List.rev !yes, List.rev !no)

;;

let (evens, odds) = partition (fun x -> x mod 2 = 0) [1;2;3;4;5;6;7;8;9;10] in
List.fold_left (+) 0 evens * 100 + List.fold_left (+) 0 odds
