Elixir Fiddle
Home
Fragments
About
Examples
Create New Fragment
Fragment: HashDict and map sum
Fragment Versions
Version
Created
1
27 Oct 2020 - 01:57
Running into a problem?
Report It!
defmodule Sum do def values(dict) do dict |> Dict.values |> Enum.sum end end # sum a HashDict hd = [ one: 1, two: 2, three: 3] |> Enum.into HashDict.new IO.puts Sum.values(hd) # sum a map map = %{ four: 4, five: 5, six: 6 } IO.puts Sum.values(map)
Run Elixir Fragment
Edit
|
Back