How to create a map in a loop in Elixir
问题 I am creating a 2d map and want to start by pre-filling it with empty values. I know the following will not work in Elixir, but this is what I am trying to do. def empty_map(size_x, size_y) do map = %{} for x <- 1..size_x do for y <- 1..size_y do map = Map.put(map, {x, y}, " ") end end end Then I will be drawing shapes onto that map like def create_room(map, {from_x, from_y}, {width, height}) do for x in from_x..(from_x + width) do for y in from_x..(from_x + width) do if # first line, or last