Gistlib Logo

gistlib

in ocaml, how do i find the max value of a list of ints? in ruby

let rec max_value lst = 
    match lst with
    | [] -> failwith "empty list"
    | [x] -> x
    | hd::tl -> max hd (max_value tl)
131 chars
6 lines
main.rb
def max_value(lst)
    lst.max
end
35 chars
4 lines

similar ruby code snippets

in ocaml, i ran this caml program: `x + 2 where x = 34` why did it fail? in ruby
remove an element from the middle of an array in ruby
insert an element into an array at a specific index in ruby
remove an element from an array at a specific index in ruby
find the index of an element in an array in ruby
remove an element from the beginning of an array in ruby
sort an array in ruby
add an element to the beginning of an array in ruby
add an element to the end of an array in ruby
remove an element from the end of an array in ruby

related categories

ocaml
ruby

gistlibby LogSnag