Advertisement
Guest User

Untitled

a guest
May 26th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. target = [6, 9, 15, -2, 92, 11]
  2.  
  3. max = fn t -> Enum.reduce(t, fn(x, acc) -> if x > acc do x else acc end end) end
  4. min = fn t -> Enum.reduce(t, fn(x, acc) -> if x < acc do x else acc end end) end
  5. avg = fn t -> Enum.sum(t) / Enum.count(t) end
  6.  
  7. "o) minimum value = " <> (min.(target) |> Integer.to_string()) |> IO.puts()
  8. "o) maximum value = " <> (max.(target) |> Integer.to_string()) |> IO.puts()
  9. "o) number of elements in the sequence = " <> (Enum.count(target) |> Integer.to_string()) |> IO.puts()
  10. "o) average value = " <> (avg.(target) |> Float.to_string()) |> IO.puts()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement