title: Generating a list of all truth assignments given a list of variables in SML?
body: <p>I'm trying to write a function in SML that given a list of variables, it returns a list of tuples of every possible boolean assignment.</p>
  <p>Essentially, I want the code to do this:</p>
  <pre><code>fun allAssignments [&quot;p&quot;, &quot;q&quot;] = 
    [[(&quot;p&quot;, True),  (&quot;q&quot;, True) ]
     [(&quot;p&quot;, True),  (&quot;q&quot;, False)]
     [(&quot;p&quot;, False), (&quot;q&quot;, True) ]
     [(&quot;p&quot;, False), (&quot;q&quot;, False)]]
  </code></pre>
  <p>However, I wrote this function and although it makes sense to me, I keep getting tycon mismatch errors and I can't rectify it:</p>
  <pre><code>fun allAssignments nil = [[]]
    | allAssignments (x::xs) = [(x, true)::allAssignments xs] @ [(x, false)::allAssignments xs]
  </code></pre>
  <p>Could anyone help point me in the right direction? Thanks!</p>