Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2014

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

Search the Archive

Re: Very simple question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg132541] Re: Very simple question
  • From: Bob Hanlon <hanlonr357 at gmail.com>
  • Date: Thu, 10 Apr 2014 03:07:17 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-outx@smc.vnet.net
  • Delivered-to: mathgroup-newsendx@smc.vnet.net
  • References: <20140409081426.C0FCB69F2@smc.vnet.net>

There is a problem with your entry of the argument to fx. If it is
re-entered, the function works partially. It works only partially because
pt2 and pt3 are undefined. Presumably you meant to use pt1 throughout.
Doing that causes fx and fy to return the same results.


fx[pt1_]:=Module[{x1,y1,x2,y2,x3,y3},

Print[pt1];

x1=pt1[[1,1]];y1=pt1[[1,2]];

x2=pt1[[2,1]];y2=pt1[[2,2]];

x3=pt1[[3,1]];y3=pt1[[3,2]];

Print[x1,y1,x2,y2,x3,y3];]


fx[{{1,2},{3,5},{4,7}}]


{{1,2},{3,5},{4,7}}


123547


fy[pt1_]:=Module[{zz,x1,y1,x2,y2,x3,y3},

zz=pt1;

Print[zz];

x1=zz[[1,1]];y1=zz[[1,2]];

x2=zz[[2,1]];y2=zz[[2,2]];

x3=zz[[3,1]];y3=zz[[3,2]];

Print[x1,y1,x2,y2,x3,y3]]


fy[{{1,2},{3,5},{4,7}}]


{{1,2},{3,5},{4,7}}


123547


All of these assignments are unnecessary.


Print@@Flatten@{{1,2},{3,5},{4,7}}


123547



Bob Hanlon




  • Prev by Date: Re: Bug with ProbabilityDistribution
  • Next by Date: Re: Bug with ProbabilityDistribution
  • Previous by thread: Re: Very simple question
  • Next by thread: Re: Very simple question