home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!gatech!purdue!mentor.cc.purdue.edu!ags
- From: ags@mentor.cc.purdue.edu (Dave Seaman)
- Newsgroups: sci.math.symbolic
- Subject: Re: Thread question in Mathematica
- Message-ID: <Bu7u7x.Eq5@mentor.cc.purdue.edu>
- Date: 7 Sep 92 16:09:32 GMT
- References: <Bu7pyr.734@mentor.cc.purdue.edu>
- Organization: Purdue University Computing Center
- Lines: 34
-
- In article <Bu7pyr.734@mentor.cc.purdue.edu> carlson@math.purdue.edu (Neil N. Carlson)
- asks essentially why Thread[{{x1, {y11, y12}}, {x2, {y21, y22}}}]
- gives {{x1, x2}, {{y11, y12}, {y21, y22}}}
- and not {{{x1, y11}, {x2, y21}}, {{x1, y12}, {x2, y22}}}
-
- Only the top-level lists (two of them, in this case) are seen by
- thread. To see what is happening, try the following:
-
- template = {{x1, y1}, {x2, y2}}
- subs = {y1 -> {y11,y12}, y2 -> {y21,y22}}
-
- and verify that
-
- Thread[template] /. subs
-
- gives the same result as
-
- Thread[template /. subs]
-
- Where template /. subs is the expression you are trying to thread, and
-
- Thread[template] /. subs
-
- is clearly equivalent to
-
- {{x1, x2}, {y1, y2}} /. subs
-
- which is
-
- {{x1, x2}, {{y11, y12}, {y21, y22}}}
-
- --
- Dave Seaman
- ags@seaman.cc.purdue.edu
-