Skip to content
This repository was archived by the owner on Jan 30, 2026. It is now read-only.

Commit d6ae62e

Browse files
committed
Refactor static OCaml multimax to use Array module function properly
1 parent 386135e commit d6ae62e

1 file changed

Lines changed: 2 additions & 11 deletions

File tree

examples/ocaml/mvalue.ml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -148,17 +148,8 @@ let m_multimax (bound_variable : m_value) (variable_array : m_array)
148148
if bound_variable.undefined then failwith "Multimax bound undefined!"
149149
else
150150
let bound = int_of_float bound_variable.value in
151+
let sub_array = Array.sub variable_array (position+1) (bound) in
151152
let get_position_value position =
152153
Array.get variable_array position
153154
in
154-
let rec multimax variable_array current_index max_index reference =
155-
let new_max =
156-
m_max reference (get_position_value current_index)
157-
in
158-
if current_index = max_index then new_max
159-
else multimax variable_array (current_index + 1) max_index new_max
160-
in
161-
if bound >= 1 then
162-
multimax variable_array (position + 1) (position + bound)
163-
(get_position_value position)
164-
else get_position_value position
155+
Array.fold_left (m_max) (get_position_value position) sub_array

0 commit comments

Comments
 (0)