Post Reply 
Why the right(); command returns both sides of an expression? (SOLVED!)
04-01-2015, 03:45 AM (This post was last modified: 04-13-2015 04:50 PM by Spybot.)
Post: #1
Why the right(); command returns both sides of an expression? (SOLVED!)
Hi Guys!

I have this code:

EXPORT TEST()
BEGIN
LOCAL M,BY,S,y,x;
INPUT(M,"Title","Label:");
BY:=CAS.y=M*CAS.x;
S:=CAS.right(BY);
MSGBOX(S);
END;

I'm trying to extract the right side of this expression (y=3x), using the right(); command, let's say I set M=3 ... then I expect to get: 3*x(no list format), but what I get is a list containing both sides of the equation. {y, 3*x}

Any Idea?

Spybot,

Spybot.
Find all posts by this user
Quote this message in a reply
04-01-2015, 04:05 PM (This post was last modified: 04-01-2015 04:06 PM by Spybot.)
Post: #2
RE: Why the right(); command returns both sides of an expression?
I've been using the right(); command in CAS view and it works correctly, but within a program it starts to misbehave (see screenshots).

       

I hope someone has an idea, why this command is behaving this way.

Thank you.

Spybot.
Find all posts by this user
Quote this message in a reply
04-01-2015, 05:29 PM
Post: #3
RE: Why the right(); command returns both sides of an expression?
The program is a HOME view construct, and right(BY) is following the rules as described in the help file for this verb.

If your program was a CAS construct, your results would perform as they do at the CAS command line.

Its the difference between HOME and CAS programs that create the results you see.
Find all posts by this user
Quote this message in a reply
04-01-2015, 07:22 PM (This post was last modified: 04-02-2015 07:43 AM by Spybot.)
Post: #4
RE: Why the right(); command returns both sides of an expression?
Hi DrD!

Is this what you mean?

#cas
test():=
BEGIN
LOCAL M,BY,S,y,x;
INPUT(M,"TITLE","LABEL:");
BY:=CAS.y=M*CAS.x;
S:=CAS.right(BY);
MSGBOX(S);
return 0;
END;
#end

Well it doesn't even execute. I went to CAS view and created this piece of code and I also checked the CAS option.
Why there's no much help about this command?

Spybot.
Find all posts by this user
Quote this message in a reply
04-13-2015, 04:49 PM (This post was last modified: 04-13-2015 08:14 PM by Spybot.)
Post: #5
RE: Why the right(); command returns both sides of an expression?
Hi Guys!!!

OK this is the way I found to solve my issue with the right(); command, from inside of a program, this command returns a list with both sides of the equation, all I did (after a long headache!) was taking the elements "Out of the list" that's it ... Done!.

Thanks to you Guys, I've been learning a lot about the Prime. here's the code... as simple as this:





EXPORT TEST()
BEGIN LOCAL M,B,BY;
INPUT({{M,[0]},{B,[0]}},"Title","m:","b:","Help");
BY:="y="+M+"*x+"+B+"";
BY:=CAS(BY);
BY:=CAS.right(BY);
PRINT();
PRINT("
Eqn. input by User:
"+exact(CAS("y="+M+"*x+"+B+""))+"
left side of the equation:
"+BY(1)+" //here is the trick.
right side of the equation:
"+BY(2)+" //here is the trick.

Thanks for Watching!");
END;

   
Spybot.

Spybot.
Find all posts by this user
Quote this message in a reply
Post Reply 




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