title: All combinations of positive and negative values of an array in Ruby
body: <p>I am wondering how to get an array in Ruby with all combinations of positive and negative values based on the values in an input array.  Order does not matter, but must be accommodating to input arrays of all sizes.  It must be flexible so negative numbers could be in the input, even though I didn't include them in the example below.</p>
  
  <p>For example:</p>
  
  <p>input:</p>
  
  <pre><code>a = [1,2,3,4]
  </code></pre>
  
  <p>output:</p>
  
  <pre><code>b = [[1,2,3,4],[1,2,3,-4],[1,2,-3,-4],[-1,2,-3,-4]...[1,-2,3,-4],[1,-2,-3,-4],[-1,-2,-3,-4],[-1,-2,-3,4],[-1,-2,3,4],[-1,2,3,4]]
  </code></pre>
  
  <p>Your help is much appreciated!</p>