Add map to list in loop

I have a map as follows

"class" => %{
      "name" => "internal",
      "id" => "2dsfcc",
      "type" => "all",
      "data" => "end",
      "status" => "Active"
    }

upon getting count from user eg: 2 I want to add the above map into the list … so that the final output will look something like

[ --------,
---------,
"calss" => %{
      "name" => "internal",
      "id" => "2dsfcc",
      "type" => "all",
      "data" => "end",
      "status" => "Active"
    },
%{
      "name" => "internal",
      "id" => "2dsfcc",
      "type" => "all",
      "data" => "end",
      "status" => "Active"
    }
]

Can Someone please help me with this?
Thanks in advance…

So you just want to duplicate it N times?

map = %{ ... }
list = Enum.map(1..n, fn _x -> map end)
2 Likes

Or just List.duplicate(map, n)

7 Likes