<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><font class="Apple-style-span" face="'Courier New'">(define (tuples xs n)</font></div><div><font class="Apple-style-span" face="'Courier New'">&nbsp; (if (&lt;= n 0)</font></div><div><font class="Apple-style-span" face="'Courier New'">&nbsp; &nbsp; &nbsp; (list empty)</font></div><div><font class="Apple-style-span" face="'Courier New'">&nbsp; &nbsp; &nbsp; (foldr append empty (map (λ (t) (map (λ (x) (cons x t)) xs)) (tuples xs (sub1 n))))))</font></div><div><br></div><div><br></div><div><div>On Feb 29, 2012, at 8:52 PM, Ashok Bakthavathsalam wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div class="ExampleText" id="30600" style="font-family: Verdana, Arial, Helvetica, sans-serif; margin-top: 10px; margin-bottom: 0px !important; margin-left: 20px; padding-top: 2px; line-height: 15px; background-color: rgb(255, 255, 255); position: static; z-index: auto; ">Again, trying to mimic something available in Mathematica (Tuples - Wolfram Mathematica 8 Documentation <a href="http://bit.ly/AgsIym">http://bit.ly/AgsIym</a>).</div>
<div class="ExampleText" id="30600" style="font-family:Verdana,Arial,Helvetica,sans-serif;margin-top:10px;margin-bottom:0px!important;margin-left:20px;padding-top:2px;line-height:15px;background-color:rgb(255,255,255)">How can this be accomplished in Racket?&nbsp;Here's an example from the Mathematica documentation.</div>
<div class="ExampleText" id="30600" style="font-family:Verdana,Arial,Helvetica,sans-serif;margin-top:10px;margin-bottom:0px!important;margin-left:20px;padding-top:2px;line-height:15px;background-color:rgb(255,255,255)">All possible 3-tuples of&nbsp;<span class="IF" style="font-family:Courier,monospace,'Courier New'!important;word-spacing:-0.25em"><img src="http://reference.wolfram.com/mathematica/ref/Files/Tuples.en/13.gif" height="14" width="7" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; vertical-align: middle; padding-bottom: 1px; "></span>&nbsp;and&nbsp;<span class="IF" style="font-family:Courier,monospace,'Courier New'!important;word-spacing:-0.25em"><img src="http://reference.wolfram.com/mathematica/ref/Files/Tuples.en/14.gif" height="14" width="7" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; vertical-align: middle; padding-bottom: 1px; "></span>:</div>
<a name="23498" style="outline-style:none;outline-width:initial;outline-color:initial;font-family:Verdana,Geneva,Arial,sans-serif;line-height:15px;background-color:rgb(255,255,255)"></a><a name="647257171" style="outline-style:none;outline-width:initial;outline-color:initial;font-family:Verdana,Geneva,Arial,sans-serif;line-height:15px;background-color:rgb(255,255,255)"></a><div class="IO" style="font-family:Verdana,Geneva,Arial,sans-serif;line-height:15px;background-color:rgb(255,255,255)">
<table class="InCell" style="border-collapse:collapse;padding-top:5px;padding-right:5px;padding-bottom:5px;padding-left:5px;margin-top:10px;margin-right:0px;margin-bottom:7px;margin-left:0px"><tbody><tr style="line-height:15px">
<td class="lab" style="font-family:Verdana,Arial,Helvetica,sans-serif;line-height:15px;padding-top:1px;padding-right:0px;padding-bottom:0px;padding-left:0px;color:rgb(69,97,173);text-align:right;width:65px;vertical-align:middle">
<a name="inoutlink" href="http://reference.wolfram.com/mathematica/ref/Tuples.html" style="outline-style:none;outline-width:initial;outline-color:initial;color:rgb(69,97,173);text-decoration:none">In[1]:=</a></td><td class="Input" style="font-family:Verdana,Geneva,Arial,sans-serif;line-height:15px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:6px;text-align:left">
<div><a name="23498" style="outline-style:none;outline-width:initial;outline-color:initial"></a><a href="http://reference.wolfram.com/mathematica/ref/Tuples.html" style="outline-style:none;outline-width:initial;outline-color:initial;color:black;text-decoration:none"><img src="http://reference.wolfram.com/mathematica/ref/Files/Tuples.en/I_2.gif" height="16" width="113" alt="Click for copyable input" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; "></a></div>
<div name="i_1_out" id="i_1_out" class="IFL" style=""><a name="23498" style="outline-style:none;outline-width:initial;outline-color:initial"></a></div></td></tr></tbody></table><table class="OCell" style="border-collapse:collapse;padding-top:5px;padding-right:5px;padding-bottom:5px;padding-left:5px;margin-right:0px;margin-bottom:4px!important;margin-left:0px">
<tbody><tr style="font-size:11px;line-height:15px"><td class="lab" style="font-family:Verdana,Arial,Helvetica,sans-serif;font-size:9px;line-height:15px;padding-top:1px;padding-right:0px;padding-bottom:0px;padding-left:0px;color:rgb(69,97,173);text-align:right;width:65px;vertical-align:middle">
<font>Out[1]=</font></td><td class="Output" style="font-family:'Courier New',Courier,monospace;font-size:12px;line-height:15px;padding-top:4px;padding-right:0px;padding-bottom:4px;padding-left:6px;text-align:left">
<font><img src="http://reference.wolfram.com/mathematica/ref/Files/Tuples.en/O_1.gif" height="15" width="547" alt="" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; "></font></td>
</tr></tbody></table><br></div><div class="IO" style="font-family:Verdana,Geneva,Arial,sans-serif;line-height:15px;background-color:rgb(255,255,255)">No, this is not homework. So, would appreciate code if available.&nbsp;</div>
<div class="IO" style="font-family:Verdana,Geneva,Arial,sans-serif;line-height:15px;background-color:rgb(255,255,255)"><br></div><div class="IO" style="font-family:Verdana,Geneva,Arial,sans-serif;line-height:15px;background-color:rgb(255,255,255)">
Thanks,</div><div class="IO" style="font-family:Verdana,Geneva,Arial,sans-serif;line-height:15px;background-color:rgb(255,255,255)"><br></div><div class="IO" style="font-family:Verdana,Geneva,Arial,sans-serif;line-height:15px;background-color:rgb(255,255,255)">
&nbsp; % ashok</div><div class="IO" style="font-family:Verdana,Geneva,Arial,sans-serif;line-height:15px;background-color:rgb(255,255,255)"><br></div>
____________________<br> &nbsp;Racket Users list:<br> &nbsp;<a href="http://lists.racket-lang.org/users">http://lists.racket-lang.org/users</a><br></blockquote></div><br></body></html>