 <p>For "6 choose 3, with replacement", you can use <a href="http://www.jsoftware.com/docs/help701/dictionary/d520.htm" rel="nofollow">catalog <code>{</code></a>:</p> <pre><code>{3#&lt;i.6 ┌─────┬─────┬─────┬─────┬─────┬─────┐ │0 0 0│0 0 1│0 0 2│0 0 3│0 0 4│0 0 5│ ├─────┼─────┼─────┼─────┼─────┼─────┤ │0 1 0│0 1 1│0 1 2│0 1 3│0 1 4│0 1 5│ ├─────┼─────┼─────┼─────┼─────┼─────┤ ... </code></pre> <p>You can take the reverse as the index of the above matrix (unraveled), feg:</p> <pre><code>(0 0 0) I.~ &gt;,{3#&lt;i.6 0 (0 1 0) I.~ &gt;,{3#&lt;i.6 6 (5 5 5) I.~ &gt;,{3#&lt;i.6 215 (4 5 1) I.~ &gt;,{3#&lt;i.6 175 175 { &gt;,{3#&lt;i.6 4 5 1 </code></pre> <p>There are some relevant essays on combinations on jsoftware.com: <a href="http://www.jsoftware.com/jwiki/Essays/Combination%20Index" rel="nofollow">Combination Index</a>, <a href="http://www.jsoftware.com/jwiki/Essays/Combinations" rel="nofollow">Combinations</a> and others.</p>