2048: Difference between revisions

359 bytes removed ,  4 years ago
→‎{{header|OCaml}}: removed tricky code
(→‎{{header|OCaml}}: added OCaml WIP)
(→‎{{header|OCaml}}: removed tricky code)
Line 5,930:
(* add a new value in a random cell containing zero *)
let rec new_value grid =
(* tricky functional version to get the cells with zeros
let _, zeros =
List.fold_left (fun (y, acc) line ->
let _, acc =
List.fold_left (fun (x, acc) v ->
if v = 0 then (x+1, (x,y)::acc) else (x+1, acc)
) (0, acc) line
in
(y+1), acc
) (0, []) grid
in
*)
(* the imperative version is more KISS *)
let zeros = ref [] in
List.iteri (fun y line ->