Sha256: a8f5ab2093546fc0495c053c100496fa852632660ec0d2fbfade3296c1ea00e3

Contents?: true

Size: 526 Bytes

Versions: 69

Compression:

Stored size: 526 Bytes

Contents

defmodule ETL do
  @doc """
  Transform an index into an inverted index.

  ## Examples

  iex> ETL.transform(%{"a" => ["ABILITY", "AARDVARK"], "b" => ["BALLAST", "BEAUTY"]])
  %{"ability" => "a","aardvark" =>"a","ballast" =>"b","beauty" =>"b"]
  """
  def transform(input) do
    input
    |> Map.to_list()
    |> invert
    |> List.flatten()
    |> Enum.into(%{})
  end

  defp invert(pairs) do
    Enum.map(pairs, fn {key, values} ->
      Enum.map(values, fn value -> {String.downcase(value), key} end)
    end)
  end
end

Version data entries

69 entries across 69 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/elixir/exercises/etl/example.exs
trackler-2.2.1.179 tracks/elixir/exercises/etl/example.exs
trackler-2.2.1.178 tracks/elixir/exercises/etl/example.exs
trackler-2.2.1.177 tracks/elixir/exercises/etl/example.exs
trackler-2.2.1.176 tracks/elixir/exercises/etl/example.exs
trackler-2.2.1.175 tracks/elixir/exercises/etl/example.exs
trackler-2.2.1.174 tracks/elixir/exercises/etl/example.exs
trackler-2.2.1.173 tracks/elixir/exercises/etl/example.exs
trackler-2.2.1.172 tracks/elixir/exercises/etl/example.exs
trackler-2.2.1.171 tracks/elixir/exercises/etl/example.exs
trackler-2.2.1.170 tracks/elixir/exercises/etl/example.exs
trackler-2.2.1.169 tracks/elixir/exercises/etl/example.exs
trackler-2.2.1.167 tracks/elixir/exercises/etl/example.exs
trackler-2.2.1.166 tracks/elixir/exercises/etl/example.exs
trackler-2.2.1.165 tracks/elixir/exercises/etl/example.exs
trackler-2.2.1.164 tracks/elixir/exercises/etl/example.exs
trackler-2.2.1.163 tracks/elixir/exercises/etl/example.exs
trackler-2.2.1.162 tracks/elixir/exercises/etl/example.exs
trackler-2.2.1.161 tracks/elixir/exercises/etl/example.exs
trackler-2.2.1.160 tracks/elixir/exercises/etl/example.exs