Re: Challenge! ....RESULTS...
- To: mathgroup at christensen.cybernetics.net
- Subject: [mg1053] Re: Challenge! ....RESULTS...
- From: jorma.virtamo at vtt.fi (Jorma Virtamo)
- Date: Fri, 12 May 1995 14:10:43 -0400
roth at sunny.mpimf-heidelberg.mpg.de. (Arnd Roth) wrote: >... >Villegas' function 3 villegas at wri.com >In[17]:= >swap[list1_List, list2_List] := Thread @ >Unevaluated[If[Random[Integer] == 0, #1, #2]& [list1, list2]] >In[18]:= Timing[Do[swap[l1,l2],{1000}]] >Out[18]= {1.44 Second, Null} > >So Robby Villegas' function 3 is fastest among the solutions I >tested. But of course there may still be room for further >speedup. Indeed, by writing the argument lists directly into the If function, swap[list1_List, list2_List] := Thread @ Unevaluated[If[Random[Integer] == 0, list1, list2]] the execution speeds up in my Pentium to 1.483 Second in contrast to 2.471 Second with the original form. -- Jorma Virtamo ======================================================= Jorma Virtamo VTT Information Technology / Telecommunications P.O. Box 1202, FIN-02044 VTT, Finland phone: +358 0 456 5612 fax: +358 0 455 0115 email: jorma.virtamo at vtt.fi web: http://www.vtt.fi/tte/ =======================================================