Post Reply 
subst command in RPN mode (bug ?)
08-12-2015, 05:15 PM
Post: #1
subst command in RPN mode (bug ?)
Hello,

I would like to report the following behavior :

In home view and in textbook entry, subst('2*Q', 'Q=2') gives 4 as expected.
However, in RPN entry :

'2*Q' Enter
'Q=2' Enter
subst(2) Enter

Returns
"subst(2*Q, (Q==2)) Error: Bad argument type"

Do I miss something? Do you confirms it's a bug ?
Thanks
Philippe
Find all posts by this user
Quote this message in a reply
08-12-2015, 05:29 PM (This post was last modified: 08-12-2015 05:32 PM by Tim Wessman.)
Post: #2
RE: subst command in RPN mode (bug ?)
Guessing it has something to do with how the arguments are being fed into the CAS. Probably something interacting with auto-evalation on the CAS side. In the list.

Thanks.

Note that the | (where) operator works fine here though without issue.

TW

Although I work for HP, the views and opinions I post here are my own.
Find all posts by this user
Quote this message in a reply
08-12-2015, 07:20 PM (This post was last modified: 08-12-2015 07:22 PM by Fortin.)
Post: #3
RE: subst command in RPN mode (bug ?)
This behavior changed from =(Q,2) to Q==2 pretty recently. I forget the specific release number though. This was also the release that changed the = behavior in Adv Graphing to == ... 7820 maybe? ...don't know if that helps...
Find all posts by this user
Quote this message in a reply
08-12-2015, 07:56 PM (This post was last modified: 08-12-2015 08:00 PM by Didier Lachieze.)
Post: #4
RE: subst command in RPN mode (bug ?)
(08-12-2015 05:15 PM)Philippe Wrote:  In home view and in textbook entry, subst('2*Q', 'Q=2') gives 4 as expected.
However, in RPN entry :

'2*Q' Enter
'Q=2' Enter
subst(2) Enter
The single quotes are lost when you press enter, on the stack you don't have '2*Q' but just 2*Q.
So you need to add another set of single quotes or double
quotes around the parameters to make it work , for example :

"'2*Q'" Enter
"'(Q=2)'" Enter
subst(2)
Find all posts by this user
Quote this message in a reply
08-12-2015, 08:55 PM
Post: #5
RE: subst command in RPN mode (bug ?)
(08-12-2015 07:56 PM)Didier Lachieze Wrote:  "'2*Q'" Enter
"'(Q=2)'" Enter
subst(2)

it works here, indeed, if I use q (lowercase letter) rather than Q:
"2*q"
"q=2"
CAS.subst(2) ==> 4

Marcelo
Find all posts by this user
Quote this message in a reply
08-12-2015, 10:15 PM
Post: #6
RE: subst command in RPN mode (bug ?)
(08-12-2015 08:55 PM)Marcelo Vanti Wrote:  
(08-12-2015 07:56 PM)Didier Lachieze Wrote:  "'2*Q'" Enter
"'(Q=2)'" Enter
subst(2)

it works here, indeed, if I use q (lowercase letter) rather than Q:
"2*q"
"q=2"
CAS.subst(2) ==> 4
It works as long as q is not defined. But if you create q, for ex by storing 0 to q then the subst command will return 0 as 2*q will be evaluated to 0 before the substitution can be done. To pass 2*q to the CAS for the substitution you need the single quotes inside the double quotes, or two levels of single quotes.
Find all posts by this user
Quote this message in a reply
08-12-2015, 10:24 PM
Post: #7
RE: subst command in RPN mode (bug ?)
(08-12-2015 08:55 PM)Marcelo Vanti Wrote:  
(08-12-2015 07:56 PM)Didier Lachieze Wrote:  "'2*Q'" Enter
"'(Q=2)'" Enter
subst(2)

it works here, indeed, if I use q (lowercase letter) rather than Q:
"2*q"
"q=2"
CAS.subst(2) ==> 4
It works as long as q is not defined. But if you create q, for ex by storing 0 to q then the subst command will return 0 as 2*q will be evaluated to 0 before the substitution can be done. To pass 2*q to the CAS for the substitution you need the single quotes inside the double quotes, or two levels of single quotes.
Find all posts by this user
Quote this message in a reply
08-13-2015, 12:36 PM
Post: #8
RE: subst command in RPN mode (bug ?)
(08-12-2015 10:24 PM)Didier Lachieze Wrote:  It works as long as q is not defined. But if you create q, for ex by storing 0 to q then the subst command will return 0 as 2*q will be evaluated to 0 before the substitution can be done. To pass 2*q to the CAS for the substitution you need the single quotes inside the double quotes, or two levels of single quotes.

You're right. I did not know the possibility of working with single quotes within double quotes, for replacement. Thanks for the tip.

Marcelo
Find all posts by this user
Quote this message in a reply
08-14-2015, 12:46 PM
Post: #9
RE: subst command in RPN mode (bug ?)
Hello, 

To summarize, let :

Form1: subst(2*q , q=2)
Form2: subst(' 2*q ' , ' q=2 ')
Form3: subst(" 2*q " , "  q=2  ")
Form4: subst(" ' 2*q' " , " ' q=2 ' ")

BAT = Bad Argument Type error
SYN = Syntax error
n.a = not applicable

Then, we have :

1) In textbook entry, if q is not defined 

            |   Home   |    CAS
---------------------------------------------
Form1     |   SYN    |    4
Form2     |   SYN    |    4
Form3     |   4       |    BAT
Form4     |   4       |    BAT
---------------------------------------------

2) In textbook entry, if q is defined (0 in this case)

            |   Home                |    CAS
---------------------------------------------
Form1     |   BAT                 |    Warning, then 0
Form2     |   4                    |    4
Form3     |   0   (no warning)   |    BAT       
Form4     |   4                    |    BAT
---------------------------------------------

3) In RPN mode (forms are of course adapted), if q is not defined

            |   Home      |   
---------------------------------------------
Form1     |   n.a        |    
Form2     |   SYN       |    can't push '2*q' on stack
Form3     |   4          |    
Form4     |   4          |    
---------------------------------------------

4) In RPN mode, if q is defined (0 in this case)

            |   Home      |   
---------------------------------------------
Form1     |   n.a        |   
Form2     |   0          |    
Form3     |   0          |    
Form4     |   4          |    
---------------------------------------------

- In RPN, we cannot push expression that contains undefined variable:
  'q' Enter produce a syntax error. We already know that this is a big regression compared to hp50...hp28. No more comment.

- The Form2 seems (at least to me !) the most suited to have a homogeneous and clean syntax between Home view and CAS, RPN and algebraic notations.

- The warning "Warning, replacing 0 by 2, a substitution variable should perhaps be purged." is useful

- May be the electronic help should be updated (in order to explain simple/double quotes)

Cheers,
Philippe
Find all posts by this user
Quote this message in a reply
Post Reply 




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