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: {x},{y} -> {x,y} ?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg68319] Re: [mg68275] Re: {x},{y} -> {x,y} ?
  • From: Murray Eisenberg <murray at math.umass.edu>
  • Date: Tue, 1 Aug 2006 06:59:47 -0400 (EDT)
  • Organization: Mathematics & Statistics, Univ. of Mass./Amherst
  • References: <eaht5b$or5$1@smc.vnet.net> <200607310745.DAA26835@smc.vnet.net>
  • Reply-to: murray at math.umass.edu
  • Sender: owner-wri-mathgroup at wolfram.com

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: x=2;Composition[f,FindMinimum][x+1,{x,a}]
  • Next by Date: Re: Tick mark function
  • Previous by thread: Re: Replacing Numbers in a List
  • Next by thread: Re: Re: Re: {x},{y} -> {x,y} ?