title: cypher function :: [(Int,Char)] -> [String]
body: <p>I want to have a function with signature :: [(Int,Char)] -> [String] which takes each Char and combines them into a list of Strings according to the Integer value in the corresponding pair...</p>
  
  <p>ie.</p>
  
  <pre><code>[(0,'A'),(1,'B'),(2,'C'),(3,'D'),(0,'E'),(1,'F'),(2,'G'),(3,'H'),(0,'I'),(1,'J'),(2,'K'),(3,'L'),(0,'M'),(1,'N'),(2,'O'),(3,'P')]
  </code></pre>
  
  <p>Should generate the list: ["MIEA","NJFB","OKGC","PLHD"]</p>
  
  <p>I've tried:</p>
  
  <pre><code>toList :: [(Int,Char)] -&gt; Int -&gt; [String]
  toList [] a = []
  toList (x:xs) a = [snd(x) | n &lt;-[0..(a-1)], fst(x) == n]:toList xs a
  </code></pre>
  
  <p>but that just gives me:</p>
  
  <pre><code>["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P"]
  </code></pre>
  
  <p>Any suggestions would be greatly appreciated.</p>