home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!sequent!ogicse!uwm.edu!linac!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!sample.eng.ohio-state.edu!purdue!mentor.cc.purdue.edu!news
- From: ags@seaman.cc.purdue.edu (Dave Seaman)
- Newsgroups: sci.math.symbolic
- Subject: Re: Thread question in Mathematica
- Message-ID: <Bu9LME.B0r@mentor.cc.purdue.edu>
- Date: 8 Sep 92 14:59:01 GMT
- Article-I.D.: mentor.Bu9LME.B0r
- References: <Bu7u7x.Eq5@mentor.cc.purdue.edu>
- Sender: news@mentor.cc.purdue.edu (USENET News)
- Organization: Purdue University
- Lines: 34
-
- In article <Bu7u7x.Eq5@mentor.cc.purdue.edu> ags@mentor.cc.purdue.edu
- (Dave Seaman) writes:
- > 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}}}
-
- After I posted this I realized that probably was not exactly what Neil
- Carlson meant to ask. The situation he described was as follows
-
- In[3]:= f[x1,{y11,y12},x2,{y21,y22}]
-
- Out[3]= f[x1, {y11, y12}, x2, {y21, y22}]
-
- In[4]:= Thread[%]
-
- Out[4]= {f[x1, y11, x2, y21], f[x1, y12, x2, y22]}
-
- In[5]:= f[a_,b_,c_,d_] := {{a,b},{c,d}}
-
- In[6]:= Thread[%3]
-
- Out[6]= {{x1, x2}, {{y11, y12}, {y21, y22}}}
-
- and the problem is that when he typed Thread[%3] in the In[6] line, %3 had
- a different value compared to when it was first printed, because of the
- intervening definition of f, which was applied first before Thread was
- called. In fact, if Neil had typed In[6] := %4, he would have obtained the
- answer he was looking for, with Thread evaluated before f.
-
- --
- Dave Seaman
- ags@seaman.cc.purdue.edu
-