home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / sci / math / symbolic / 3333 < prev    next >
Encoding:
Text File  |  1992-12-24  |  1.2 KB  |  36 lines

  1. Newsgroups: sci.math.symbolic
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!sdd.hp.com!ux1.cso.uiuc.edu!news.cso.uiuc.edu!gaylord.slip.uiuc.edu!gaylord
  3. From: Richard J. Gaylord <gaylord@ux1.cso.uiuc.edu>
  4. Subject: "shut up and deal the cards"
  5. Message-ID: <Bzs70r.B1B@news.cso.uiuc.edu>
  6. X-Xxdate: Thu, 24 Dec 92 14:46:58 GMT
  7. Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
  8. X-Useragent: Nuntius v1.1.1d13
  9. Organization: University of Illinois
  10. Date: Thu, 24 Dec 1992 20:46:01 GMT
  11. X-Xxmessage-Id: <A75F7DE25301164B@gaylord.slip.uiuc.edu>
  12. Lines: 22
  13.  
  14. i figured out a way to deal a bridge hand that's more than three times
  15. faster than the  version i posted a littel while ago.. 
  16.  
  17. deck = Flatten[Outer[List,{c,d,h,s},Join[Range[2,10],{J,Q,K,A}]],1];
  18.  
  19. SeedRandom[2]
  20. Timing[Partition[Transpose[Sort[Transpose[{Table[Random[],{52}],
  21. deck}]]][[2]],13];]
  22. {0.166667 Second, Null}
  23.  
  24. SeedRandom[2]
  25.  Timing[Partition[Map[#[[2]]&,
  26. Sort[Array[{Random[],#}&,52]]]/.Thread[Range[52]->deck],13];]
  27. {0.516667 Second, Null}
  28.  
  29. =================
  30.  
  31. the speed comes (i think) because i directly create the list
  32. {...{Random[], card}...} and use Transpose rather than a replacement rule
  33. (once again reaffirming the efficiency of functional programming.)
  34.  
  35. good night to all and to all, a good night.
  36.