Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
15
Task/Equilibrium-index/OCaml/equilibrium-index.ocaml
Normal file
15
Task/Equilibrium-index/OCaml/equilibrium-index.ocaml
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
let lst = [ -7; 1; 5; 2; -4; 3; 0 ]
|
||||
let sum = List.fold_left ( + ) 0 lst
|
||||
|
||||
let () =
|
||||
let rec aux acc i left right = function
|
||||
| x::xs ->
|
||||
let right = right - x in
|
||||
let acc = if left = right then i::acc else acc in
|
||||
aux acc (succ i) (left + x) right xs
|
||||
| [] -> List.rev acc
|
||||
in
|
||||
let res = aux [] 0 0 sum lst in
|
||||
print_string "Results:";
|
||||
List.iter (Printf.printf " %d") res;
|
||||
print_newline ()
|
||||
Loading…
Add table
Add a link
Reference in a new issue