Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: Re: {x},{y} -> {x,y} ?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg68351] Re: [mg68319] Re: [mg68275] Re: {x},{y} -> {x,y} ?
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Wed, 2 Aug 2006 05:24:07 -0400 (EDT)
  • References: <eaht5b$or5$1@smc.vnet.net> <200607310745.DAA26835@smc.vnet.net> <200608011059.GAA09916@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Your last example is not really due to the fact that f is a "function  
other than List" but is a feature of threading over single elements.  
One can see in very simpler examples, e.g.


Thread[Thread[{1, {2, 3}}]]


{{1, 1}, {2, 3}}

Of course successive applications of Thread will now have the  
involutive property:


NestList[Thread,{1, {2, 3}},5]


{{1, {2, 3}}, {{1, 2},
    {1, 3}}, {{1, 1}, {2, 3}},
   {{1, 2}, {1, 3}},
   {{1, 1}, {2, 3}},
   {{1, 2}, {1, 3}}}


Andrzej Kozlowski


On 1 Aug 2006, at 12:59, Murray Eisenberg wrote:

> This solution (also posted by Bob Hanlon [mg68257] and Oleksandr  
> Pavlyk
> [mg68254], and appearing as well in Michael Trott's "The Mathematica
> Guidebook for Programming") is very interesting, because Thread is its
> own functional inverse here:
>
>     x = Range[3]; y = 10*Range[3];
>     Thread[{x, y}]
>     Thread[%]
> {{1, 10}, {2, 20}, {3, 30}}
> {{1, 2, 3}, {10, 20, 30}}
>
> In general, if x and y are any lists of the same length, then:
>
>     Thread @ Thread[List[x, y]] == List[x, y]
> True
>
> (And similarly for n instead of 2 such lists).
>
> But for functions f other than List, it is not necessarily the case  
> that
>
>     Thread@Thread[f[x, y]] == f[x, y]
>
> is true. For example:
>
>     f[x_,y_] := {{x[[1]], y[[2]]},y[[1]]}
>     x=Range[3];y=10*Range[3];
>     f[x,y]
>     Thread[f[x,y]]
>     Thread@Thread[f[x,y]]
> {{1,20},10}
> {{1, 10}, {20, 10}}
> {{1,20},{10,10}}
>
> What more can be said about such counterexamples?
>
> Stratocaster wrote:
>> "AngleWyrm" <anglewyrm at yahoo.com> wrote in message
>> news:eaht5b$or5$1 at smc.vnet.net...
>>> Hi,
>>> I have two lists, a set of x values and a set of y values. How do I
>>> convert
>>> them to one list of { {x1,y1},{x2,y2} } pairs?
>>>
>>
>> x = {set of X values};
>> y = {set of Y values};
>>
>> Thread[{x,y}]
>
> -- 
> Murray Eisenberg                     murray at math.umass.edu
> Mathematics & Statistics Dept.
> Lederle Graduate Research Tower      phone 413 549-1020 (H)
> University of Massachusetts                413 545-2859 (W)
> 710 North Pleasant Street            fax   413 545-1801
> Amherst, MA 01003-9305
>


  • Prev by Date: Re: Re: Using implicit information about row indices
  • Next by Date: a Quaternion quadratic level Pisot polynomial
  • Previous by thread: Re: Re: {x},{y} -> {x,y} ?
  • Next by thread: Re: Tick mark function