Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #16752 > unrolled thread

Very simple question

Started by"Ste[hen Gray" <stevebg@roadrunner.com>
First post2014-04-09 08:14 +0000
Last post2014-04-09 08:46 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Very simple question "Ste[hen Gray" <stevebg@roadrunner.com> - 2014-04-09 08:14 +0000
    Re: Very simple question "Nasser M. Abbasi" <nma@12000.org> - 2014-04-09 08:46 +0000

#16752 — Very simple question

From"Ste[hen Gray" <stevebg@roadrunner.com>
Date2014-04-09 08:14 +0000
SubjectVery simple question
Message-ID<li2vhl$pd6$1@smc.vnet.net>
I've been away from Mathematica for about 7 years.
Can anyone tell me why function fx gives an error message but fy does 
not? They look functionally the same to me.
Please send me an email about this.

fx[ptl_] := Module[{x1, y1, x2, y2, x3, y3},
   Print[pt1];
   x1 = pt1[[1, 1]]; y1 = pt1[[1, 2]];
   x2 = pt2[[2, 1]]; y2 = pt2[[2, 2]];
   x3 = pt3[[3, 1]]; y3 = pt3[[3, 2]];
   Print[x1, y1, x2, y2, x3, y3];
   ]
fx[{{1, 2}, {3, 5}, {4, 7}}]

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}}]

Thank you.
Steve Gray
stevebg@roadrunner.com

[toc] | [next] | [standalone]


#16757

From"Nasser M. Abbasi" <nma@12000.org>
Date2014-04-09 08:46 +0000
Message-ID<li31ds$q2l$1@smc.vnet.net>
In reply to#16752
On 4/9/2014 3:14 AM, Ste[hen Gray wrote:
> I've been away from Mathematica for about 7 years.
> Can anyone tell me why function fx gives an error message but fy does
> not? They look functionally the same to me.
> Please send me an email about this.
>
> fx[ptl_] := Module[{x1, y1, x2, y2, x3, y3},
>     Print[pt1];
>     x1 = pt1[[1, 1]]; y1 = pt1[[1, 2]];
>     x2 = pt2[[2, 1]]; y2 = pt2[[2, 2]];
>     x3 = pt3[[3, 1]]; y3 = pt3[[3, 2]];
>     Print[x1, y1, x2, y2, x3, y3];
>     ]
> fx[{{1, 2}, {3, 5}, {4, 7}}]
>

First problem: the input is "ptl". Then inside the module
you use "pt1".

One uses the lower case letter L, and the second uses the number 1.

The second problem: There is no such thing as "pt2" and "pt3"
anywhere. Where did these come from?

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

This one uses "pt1" as input and uses "pt1" inside the module.
So this one is correct.

--Nasser

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web