Q:

nested list comprehension in elixir

In order to learn Elixir I would like to resolve this problem: https://projecteuler.net/problem=96
In order to go through the board I would start like that:
In python:
row_indexes = ["A","B","C","D","E","F","G","H","I"];
col_indexes = ["1","2","3","4","5","6","7","8","9"];
row_box_indexes = [["A","B","C"],["D","E","F"],["G","H","I"]];
col_box_indexes = [["1","2","3"],["4","5","6"],["7","8","9"]];

cols = [[r+c for r in row_indexes] for c in col_indexes]
rows = [[r+c for c in col_indexes] for r in row_indexes]
boxes = [[r+c for c in C for r in R] for C in col_box_indexes for R in row_box_indexes]

print(cols) // [['A1', 'B1', 'C1', 'D1', 'E1', 'F1', 'G1', 'H1', 'I1'],...,['A9', 'B9', 'C9', 'D9', 'E9', 'F9', 'G9', 'H9', 'I9']]

I'm struggling using list comprehension in elixir I tried this but it puts me one list with all my result
row_indexes = ["A","B","C","D","E","F","G","H","I"];
col_indexes = ["1","2","3","4","5","6","7","8","9"];
row_box_indexes = [["A","B","C"],["D","E","F"],["G","H","I"]];
col_box_indexes = [["1","2","3"],["4","5","6"],["7","8","9"]];

# in iex
for c <- col_indexes,
    x <- (for r <- row_indexes, do: r<>c),
    do: x

# ["A1", "B1", "C1", "D1", "E1", "F1", "G1", "H1", "I1", "A2", "B2", "C2", "D2",..., "I5", "A6", "B6", "C6", "D6", "E6", ...]

1) is it a good the good way to resolve this problem in Elixir ?
2) could you explain me how I can reach the same result as print(cols) in python ?
Thank you :)

A:

Thank you Lauro for your answer!
So yes both comprehension are different and it's not possible to do the same thing in python and in Elixir
This solution (probably not the best...) is longer than the python one but it works:
  @doc """
  generate all the rows coordinates
      [[{0,0},{1,0},{2,0},{3,0},{4,0},{5,0},{6,0},{7,0},{8,0},],...]
  """
  def create_rows(size \\ 9) do
    Enum.reduce(0..size - 1, [], fn(ord,acc) ->
      col = Enum.reduce(0..size - 1, [], fn(abs, accu) ->
        [{abs,ord}|accu]
      end)
      |> Enum.reverse
      [col | acc]
    end)
    |> Enum.reverse
  end

It will generate this:
[
  [{0,0},{1,0},{2,0},{3,0},{4,0},{5,0},{6,0},{7,0},{8,0},],
  [{0,1},{1,1},{2,1},{3,1},{4,1},{5,1},{6,1},{7,1},{8,1},],
  [{0,2},{1,2},{2,2},{3,2},{4,2},{5,2},{6,2},{7,2},{8,2},],
  [{0,3},{1,3},{2,3},{3,3},{4,3},{5,3},{6,3},{7,3},{8,3},],
  [{0,4},{1,4},{2,4},{3,4},{4,4},{5,4},{6,4},{7,4},{8,4},],
  [{0,5},{1,5},{2,5},{3,5},{4,5},{5,5},{6,5},{7,5},{8,5},],
  [{0,6},{1,6},{2,6},{3,6},{4,6},{5,6},{6,6},{7,6},{8,6},],
  [{0,7},{1,7},{2,7},{3,7},{4,7},{5,7},{6,7},{7,7},{8,7},],
  [{0,8},{1,8},{2,8},{3,8},{4,8},{5,8},{6,8},{7,8},{8,8},],
]

