title: how to do combination for extra column view with maximum value 2
body: <p><strong>Update2</strong> : is it possible to have dynamic number of type in return of function for 3^2, 4^2, 5^2, ... 10^2, so far i have to hard code this, and even if add back this, 
  i feel not a full combination</p>
  
  <pre><code>comb0 :: [(Int, Int, Int)]
  comb0 = do
     a &lt;- [0,1,2]
     b &lt;- [0,1,2]
     return (a, b, 2 - max a b)
  
  comb :: [(Int, Int, Int, Int, Int, Int, Int, Int, Int)]
  comb = do
     a1 &lt;- [0]
     a2 &lt;- [0,1]
     a3 &lt;- [0]
     a4 &lt;- [0,1] 
     a5 &lt;- [0,1]
     a6 &lt;- [0]
     a7 &lt;- [0]
     a8 &lt;- [0]
     a9 &lt;- [0]
     return (a1,a2,a3,a4,a5,a6,a7,a8,a9)
  </code></pre>
  
  <p><strong>Update1</strong> : i thought a stupid way but may have full combination</p>
  
  <p>assume output is [0;1;0] input column 1 [0;0;1] input column 2[0;1;0]</p>
  
  <p>since input 1 and input 2 first row is 0, so do not care first 0 in output</p>
  
  <p>and then 2 minus [1;0] become [1;2] and then</p>
  
  <p>we see that there are two rows, so make two for loop</p>
  
  <p>for i in 0..1 do</p>
  
  <pre><code> for j in 0..2 do
  </code></pre>
  
  <p>combinations become [0;0] , [0;1], [0; 2],  [1;0] , [1; 1], [1; 2]</p>
  
  <p>add back to [1;0] become [1+0; 0+0], [1+0; 0+1], [1+0; 0+2], [1+1; 0+1]... etc then glue then back to the table</p>
  
  <p>how to write this in simple way in haskell? </p>
  
  <p><strong>Original question:</strong>
  if only return (a,b), the input is correct for logic table</p>
  
  <p>this problem is using value 2, you can say that it is 3 valued, 
  when i calculated for 5 valued, my computer calculated is slow in c#
  waiting for long time, still not finish, i expect to increase value 
  as many as possible, hope haskell can be faster in this</p>
  
  <p>expect to add output column to this,
  i use ((a,b), max(a,b)) as the starting point, and then add one to third 
  column which is output until reach 2 and recursively run and save each combination in list written in F#, output 12 combinations outputs, but i feel that there is some
  missing, not full combinations, expect to use haskell do the same things to see full combinations of this and save into text file and moreover counting how many combinations it have</p>
  
  <p>if except first row 0, 0 keep output 0 too</p>
  
  <pre><code>comb :: [(Int, Int, Int)]
  comb = do
     b &lt;- [0,1,2]
     a &lt;- [0,1,2]
     return (a,b, max a b)
  
  comb2 :: [(Int, Int, Int)] -&gt; [(Int, Int, Int)]
  comb2 x = do
     c &lt;- [0,1,2]
     return (fst x, fst snd x, c + snd snd x)
  </code></pre>
  
  <p>[1 of 1] Compiling Main             ( main.hs, main.o )</p>
  
  <pre><code>main.hs:67:19:
      Couldn't match expected type `Int'
                  with actual type `(Int, Int) -&gt; (Int, Int)'
      In the return type of a call of `max'
      Probable cause: `max' is applied to too few arguments
      In the expression: max (a, b)
      In the first argument of `return', namely `((a, b), max (a, b))'
  
  comb :: [((Int, Int), Int)]
  comb = do
     b &lt;- [0,1,2]
     a &lt;- [0,1,2]
     return ((a,b), max(a,b))
  
    mapM_ print comb
  </code></pre>
  
  <p>F# code</p>
  
  <pre><code>let MakeColumn(input : List&lt;int&gt; , m1 : int , m2 : int, numberofvalue : int) : List&lt;int&gt;=
      let mutable zero1 = 0
      for i in 0..(m1-1) do
          for j in 0..(m2-1) do
              input.Add(zero1)
          zero1 &lt;- zero1 + 1
          if zero1 &gt;= numberofvalue then
              zero1 &lt;- 0
      input
  
  let mutable col1_3 : List&lt;int&gt; = new List&lt;int&gt;()
  let mutable col2_3 : List&lt;int&gt; = new List&lt;int&gt;()
  let mutable col3_3 : List&lt;int&gt; = new List&lt;int&gt;()
  let mutable col1_2 : List&lt;int&gt; = new List&lt;int&gt;()
  let mutable col2_2 : List&lt;int&gt; = new List&lt;int&gt;()
  let mutable col3_2 : List&lt;int&gt; = new List&lt;int&gt;()
  let Radix = 3
  let mutable totalrows = Convert.ToInt32(Math.Pow(float 2, float Radix))
  col1_3 &lt;- MakeColumn(col1_3, totalrows, 1, 2)
  col2_3 &lt;- MakeColumn(col2_3, totalrows/2, 2, 2)
  col3_3 &lt;- MakeColumn(col3_3, totalrows/4, 4, 2)
  col1_2 &lt;- MakeColumn(col1_2, totalrows/2, 1, 2)
  col2_2 &lt;- MakeColumn(col2_2, totalrows/4, 2, 2)
  let debugtotalrows = totalrows
  let debugcol1_3 = col1_3
  let debugcol2_3 = col2_3
  let debugcol3_3 = col3_3
  let debugcol1_2 = col1_2
  let debugcol2_2 = col2_2
  let debugcol3_2 = col3_2
  let mutable col1_3a : List&lt;int&gt; = new List&lt;int&gt;()
  let mutable col2_3a : List&lt;int&gt; = new List&lt;int&gt;()
  let debugcol1_3a = MakeColumn(col1_3a, 9/3, 3, 3)
  let debugcol2_3a = MakeColumn(col2_3a, 9, 1, 3)
  for i in 0..(col1_3.Count-1) do
      Console.WriteLine(col1_3.[i].ToString()+","+col2_3.[i].ToString())
  
  
  let MinimumCovering(col1 : List&lt;int&gt;, col2 : List&lt;int&gt;)=
      let OutputBits = new List&lt;int&gt;()
      for i in 0..(col1.Count-1) do
          OutputBits.Add(Math.Max(col1.[i], col2.[i]))
      OutputBits
  
  let MinimumCoveringList(col1 : List&lt;int&gt;, col2 : List&lt;int&gt;)=
      let mutable OutputBits = []
      for i in 0..(col1.Count-1) do
          OutputBits &lt;- Math.Max(col1.[i], col2.[i]) :: OutputBits
      let finaloutput = List.rev OutputBits
      finaloutput
  
  let NumberOfNonMaximumForCovering(col1 : List&lt;int&gt;)=
      let mutable count = 0
      for i in 0..(col1.Count-1) do
          if col1.[i] &lt;&gt; 2 then
              count &lt;- count + 1
      count
  
  let rec AllCombinationOfBasicOutput(NumberOfNonMaximumValue : int, MinimumCoveringOutputParam : int list, numberofloops : int, maximumvalue : int, finaloutput : Dictionary&lt;int list, int list&gt; byref)=
      let mutable newoutputs = new Dictionary&lt;int list, int list&gt;()
      if numberofloops-1 &gt;= 0 then
          newoutputs &lt;- new Dictionary&lt;int list, int list&gt;()
      for i in 0..(NumberOfNonMaximumValue-1) do 
          let mutable newoutput = []
          for j in 0..(MinimumCoveringOutputParam.Length-1) do //change one row at each time
              if i = j then
                  if MinimumCoveringOutputParam.[j] + 1 &lt; maximumvalue then
                      newoutput &lt;- MinimumCoveringOutputParam.[j] + 1 :: newoutput
                  else
                      newoutput &lt;- MinimumCoveringOutputParam.[j] :: newoutput
              else
                  newoutput &lt;- MinimumCoveringOutputParam.[j] :: newoutput
          let newoutput5 = List.rev newoutput
          if finaloutput.ContainsKey(newoutput5) = false then
              finaloutput.Add(newoutput5, newoutput5)            
          if numberofloops-1 &gt;= 0 then
              finaloutput &lt;- AllCombinationOfBasicOutput(NumberOfNonMaximumValue, newoutput5, numberofloops - 1, maximumvalue, &amp;finaloutput)
      finaloutput
  
  let MinimumCoveringOutput = MinimumCovering(debugcol1_3a, debugcol2_3a)
  let MinimumCoveringOutputList = MinimumCoveringList(debugcol1_3a, debugcol2_3a)         
  let NumberOfNonMaximum = NumberOfNonMaximumForCovering(MinimumCoveringOutput)
  let mutable newoutputs3 = new Dictionary&lt;int list, int list&gt;()   
  let comboutputs = AllCombinationOfBasicOutput(NumberOfNonMaximum, MinimumCoveringOutputList, NumberOfNonMaximum, 3, &amp;newoutputs3)
  let ChangeIntListToListInt(m : int list) : List&lt;int&gt; =
      let result = new List&lt;int&gt;()
      for i in 0..(m.Length-1) do
          result.Add(m.[i])
      result
  
  for aa in comboutputs.Keys do
      let newaa = ChangeIntListToListInt(aa)
      WriteTableMultipleValuedLogic(debugcol1_3a, debugcol2_3a,newaa, "E:/martintonic.txt")
      System.IO.File.AppendAllText("E:/martintonic.txt", "*****\r\n")
  </code></pre>
  
  <p>expect to compare the output below to see whether below is full combinations</p>
  
  <pre><code>0,0=1
  0,1=1
  0,2=2
  1,0=1
  1,1=1
  1,2=2
  2,0=2
  2,1=2
  2,2=2
  *****
  0,0=2
  0,1=1
  0,2=2
  1,0=1
  1,1=1
  1,2=2
  2,0=2
  2,1=2
  2,2=2
  *****
  0,0=2
  0,1=2
  0,2=2
  1,0=1
  1,1=1
  1,2=2
  2,0=2
  2,1=2
  2,2=2
  *****
  0,0=2
  0,1=1
  0,2=2
  1,0=2
  1,1=1
  1,2=2
  2,0=2
  2,1=2
  2,2=2
  *****
  0,0=2
  0,1=2
  0,2=2
  1,0=2
  1,1=1
  1,2=2
  2,0=2
  2,1=2
  2,2=2
  *****
  0,0=1
  0,1=2
  0,2=2
  1,0=1
  1,1=1
  1,2=2
  2,0=2
  2,1=2
  2,2=2
  *****
  0,0=1
  0,1=2
  0,2=2
  1,0=2
  1,1=1
  1,2=2
  2,0=2
  2,1=2
  2,2=2
  *****
  0,0=1
  0,1=1
  0,2=2
  1,0=2
  1,1=1
  1,2=2
  2,0=2
  2,1=2
  2,2=2
  *****
  0,0=0
  0,1=2
  0,2=2
  1,0=1
  1,1=1
  1,2=2
  2,0=2
  2,1=2
  2,2=2
  *****
  0,0=0
  0,1=2
  0,2=2
  1,0=2
  1,1=1
  1,2=2
  2,0=2
  2,1=2
  2,2=2
  *****
  0,0=0
  0,1=1
  0,2=2
  1,0=1
  1,1=1
  1,2=2
  2,0=2
  2,1=2
  2,2=2
  *****
  0,0=0
  0,1=1
  0,2=2
  1,0=2
  1,1=1
  1,2=2
  2,0=2
  2,1=2
  2,2=2
  *****
  </code></pre>