home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / sci / math / symbolic / 2337 < prev    next >
Encoding:
Internet Message Format  |  1992-09-08  |  1.2 KB

  1. Path: sparky!uunet!gatech!purdue!mentor.cc.purdue.edu!ags
  2. From: ags@mentor.cc.purdue.edu (Dave Seaman)
  3. Newsgroups: sci.math.symbolic
  4. Subject: Re: Thread question in Mathematica
  5. Message-ID: <Bu7u7x.Eq5@mentor.cc.purdue.edu>
  6. Date: 7 Sep 92 16:09:32 GMT
  7. References: <Bu7pyr.734@mentor.cc.purdue.edu>
  8. Organization: Purdue University Computing Center
  9. Lines: 34
  10.  
  11. In article <Bu7pyr.734@mentor.cc.purdue.edu> carlson@math.purdue.edu (Neil N. Carlson) 
  12.  asks essentially why Thread[{{x1, {y11, y12}}, {x2, {y21, y22}}}]
  13. gives                 {{x1, x2}, {{y11, y12}, {y21, y22}}}
  14. and not               {{{x1, y11}, {x2, y21}}, {{x1, y12}, {x2, y22}}}
  15.  
  16. Only the top-level lists (two of them, in this case) are seen by
  17. thread. To see what is happening, try the following:
  18.  
  19.         template = {{x1, y1}, {x2, y2}}
  20.     subs = {y1 -> {y11,y12}, y2 -> {y21,y22}}
  21.     
  22. and verify that
  23.  
  24.     Thread[template] /. subs
  25.     
  26. gives the same result as
  27.  
  28.     Thread[template /. subs]
  29.     
  30. Where template /. subs is the expression you are trying to thread, and
  31.  
  32.     Thread[template] /. subs 
  33.     
  34. is clearly equivalent to 
  35.  
  36.     {{x1, x2}, {y1, y2}} /. subs
  37.     
  38. which is
  39.  
  40.     {{x1, x2}, {{y11, y12}, {y21, y22}}}
  41.  
  42. -- 
  43. Dave Seaman
  44. ags@seaman.cc.purdue.edu
  45.