Thread Closed 
Reading one or two arguments
03-14-2021, 10:08 PM
Post: #7
RE: Reading one or two arguments
You don't need to return to the stack if a complex, Reading Ans(N) from
the stack does not remove it from the stack.

You can use affix() to turn a a 2-dimension vector or a point into a
complex notation.:
affix([4,6]); goes to (4,6). And affix((4,6)) goes to (4,6) or to 4+i*6
You have to know that Prime consider a point (a1,b1) being same as a1+i*6
Whether it is transformed into a1+i*6 depends on your calculator settings
of complex. Look up the settings for this. If your setting are a+b*i then
both [a1,b1] and (a1,b1) transform to a1+i*b1

The other poster showed you how to use IF... THEN...ELSE...END
clause to discriminate between the arguments. Whether you put these arguments
in via Ans(1) and Ans(2), or as doing it via the command line, as typing up
the Program name; MyPrg(), and using the direction button (the wriggling rocker
wheel under your thumb) to move it over the arguments for highlighting and Enter
them to MyPrg(here, and_here), does not matter. se all down how easy it is to convert a polar to a vector.

It' s not an all safe solution using eval as recommended. Whether
a name or an Integer results using this command still relies on
interaction with other commands in the executed program. And
whether using upper or under case letters for the function name,
and whether execution are in HOME or in CAS mode.

A better solution wil be doing a survey, when the program are
under development. Write this in the program under development:

ty:=TYPE((a1+b1*i));
RETURN(TY);

Now you can see what it returns to the window. For a complex
it should be 3.

If you want to use TYPE() to decide whether a variable are a complex
or a FLOAT (in most cases a 0 in HOME. but in CAS it sometimes is a 1 or a DOM_FLOAT). A name for it can not be used in an IF THEN ELSE END decision, because DOM_FLOAT isn't a string. So you cannot write IF ty==DOM_FLOAT THEN ...ELSE...END;
not either can you write IF ty=="DOM_FLOAT" THEN ...ELSE ...END;
The same is true with DOM_COMPLEX. You get an error!. But names can
be used in the EQ() clause, there it works. I have done this and seen it, anyway.

So what then:
If you return shows you a "3" for complex then use it in the decision clause.
It's easy to separate a complex. In my last post you saw that a polar point
is written as a vector [r1,arg1]. So, if Z!:=[r1,arg1]; then -

pt is a LOCAL or an EXPORT, if you're gone to use it for another program as a Global. Instead to transform to polar coor, you could transform to a vector
and use affix() to transform to a complex

IF ty==3 THEN
pt:=Z1[1]*[cos(Z1[2]),sin(Z1[2])]; //cartecian coor
pt:= affix(pt); //pt is now a complex
ELSE
...
END;
Find all posts by this user
Thread Closed 


Messages In This Thread
Reading one or two arguments - HillyBoy - 03-13-2021, 04:18 PM
RE: Reading one or two arguments - essen - 03-13-2021, 08:40 PM
RE: Reading one or two arguments - Han - 03-14-2021, 05:20 AM
RE: Reading one or two arguments - essen - 03-14-2021, 11:54 AM
RE: Reading one or two arguments - essen - 03-14-2021 10:08 PM
RE: Reading one or two arguments - essen - 03-15-2021, 12:27 PM
RE: Reading one or two arguments - essen - 03-16-2021, 09:00 PM
RE: Reading one or two arguments - Gene - 03-17-2021, 08:55 PM



User(s) browsing this thread: 1 Guest(s)