title: Partial cartesian product (ensure one value in each set)
body: <p>Given a set of items <code>[z,a,b,c]</code> I want to find the "cartesian power" (cartesian product with itself <em>n</em> times) but <strong>only those results that have a <code>z</code> in them</strong>. For example:</p>
  
  <pre><code>normal_values = ["a","b","c"]
  p limited_cartesian( normal_values, "z", 2 )
  #=&gt; [
  #=&gt;   ["z", "z"]
  #=&gt;   ["z", "a"]
  #=&gt;   ["z", "b"]
  #=&gt;   ["z", "c"]
  #=&gt;   ["a", "z"]
  #=&gt;   ["b", "z"]
  #=&gt;   ["c", "z"]
  #=&gt; ]
  </code></pre>
  
  <p>I can do this by spinning through the full set and skipping entries that don't have the special value, but I'm wondering if there's a simpler way. Preferably one that allows me to only evaluate the desired entries lazily, without wasting time calculating unwanted entries.</p>
  
  <pre><code>def limited_cartesian( values, special, power )
    [special, *values].repeated_permutation(power)
                      .select{ |prod| prod.include?( special ) }
  end
  </code></pre>