In Ruby, you can use the max
method on an array to find the maximum element in the array. Here is an example:
main.rb36 chars3 lines
In OCaml, you can achieve a similar result using the List.fold_left
function to iterate over the list and keep track of the maximum element. Here is an example:
171 chars7 lines
This OCaml code defines a function find_max
which uses List.fold_left
to find the maximum element in a list.
gistlibby LogSnag