Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- target = [6, 9, 15, -2, 92, 11]
- max = fn t -> Enum.reduce(t, fn(x, acc) -> if x > acc do x else acc end end) end
- min = fn t -> Enum.reduce(t, fn(x, acc) -> if x < acc do x else acc end end) end
- avg = fn t -> Enum.sum(t) / Enum.count(t) end
- "o) minimum value = " <> (min.(target) |> Integer.to_string()) |> IO.puts()
- "o) maximum value = " <> (max.(target) |> Integer.to_string()) |> IO.puts()
- "o) number of elements in the sequence = " <> (Enum.count(target) |> Integer.to_string()) |> IO.puts()
- "o) average value = " <> (avg.(target) |> Float.to_string()) |> IO.puts()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement