title: Tricky list transformation in Haskell
body: <p>The first list has length 27, I want to transform this into a list of length 9 such that the list indexes are combined as shown in the second list below:</p>
  
  <pre><code>[[Just 3,Just 6,Nothing],[Nothing,Just 7,Just 1],[Just 2,Nothing,Nothing]
  ,[Nothing,Just 5,Nothing],[Nothing,Nothing,Nothing],[Just 1,Just 8,Nothing]
  ,[Nothing,Nothing,Just 9],[Just 2,Nothing,Just 4],[Just 7,Nothing,Nothing]
  ,[Nothing,Nothing,Nothing],[Nothing,Just 1,Just 3],[Nothing,Just 2,Just 8]
  ,[Just 4,Nothing,Nothing],[Just 5,Nothing,Just 2],[Nothing,Nothing,Just 9]
  ,[Just 2,Just 7,Nothing],[Just 4,Just 6,Nothing],[Nothing,Nothing,Nothing]
  ,[Nothing,Nothing,Just 5],[Just 3,Nothing,Just 8],[Just 9,Nothing,Nothing]
  ,[Nothing,Just 8,Just 3],[Nothing,Nothing,Nothing],[Nothing,Just 6,Nothing]
  ,[Nothing,Nothing,Just 7],[Just 6,Just 9,Nothing],[Nothing,Just 4,Just 3]]
  
  [[1,4,7],[2,5,8],[3,6,9]
  ,[10,13,16],[11,14,17],[12,16,18]
  ,[19,22,25],[20,23,26],[21,24,27]
  </code></pre>
  
  <p>What would be the simplest sulution to this problem? </p>
  
  <p>I have been trying to use <code>foldr</code>but I just can figure out how to have each element put in a different list depending on the index, there is a clear pattern in how the data is combined so there must be some simple solution that exploits this pattern...</p>