New answers tagged

0

defmodule Test do def contains?(term, elem) do elem in term end def test do elems = [1,2,3] terms = [[1,2], [2,3]] for e <- elems, reduce: %{} do acc -> key = Enum.find(terms, &contains?(&1, e)) Map.update(acc, key, [e], &[e|&1]) end #=> %{[1, 2] => [2, 1], [2, 3] => [...


Top 50 recent answers are included