Post Reply 
[CAS] Detection of errors in the program editor
10-19-2016, 12:16 AM
Post: #1
[CAS] Detection of errors in the program editor
Hello,

1: why the sentence "if ( (a:= 5) and true) then" this has the final state TRUE?, the left side of the comparison is an assignment, why evaluates to true?

PHP Code:
#cas
  
test( ):=
begin
  
print;
  
//print (5 != 6);
  //print (5 <> 6);
  //print (5 ≠ 6);

  
if ( (a:= 5) and truethen
    
print("yes");
  else
    print(
"no");
  
end;
  return 
"Done";
end;
#end 

test( ); returns "YES"
Find all posts by this user
Quote this message in a reply
10-19-2016, 01:52 AM
Post: #2
RE: [CAS] Detection of errors in the program editor
ok

now (a = 5) and true -> false, why?

PHP Code:
#cas
  
test( ):=
begin
  
print;
  if( (
5) and truethen
    
print("yes");
  else
    print(
"no");
  
end;
  return 
"Done";
end;
#end 

test( ); returns "NO"
Find all posts by this user
Quote this message in a reply
10-19-2016, 03:24 AM
Post: #3
RE: [CAS] Detection of errors in the program editor
for CAS use a == 5

Viga C | TD | FB
Visit this user's website Find all posts by this user
Quote this message in a reply
10-19-2016, 03:37 AM
Post: #4
RE: [CAS] Detection of errors in the program editor
it may be that a user instead of typing ( == ) write one equal ( = ), then that means for the CAS (var = number)?
Find all posts by this user
Quote this message in a reply
10-20-2016, 05:26 PM (This post was last modified: 10-20-2016 05:28 PM by toml_12953.)
Post: #5
RE: [CAS] Detection of errors in the program editor
(10-19-2016 12:29 PM)moonbeam Wrote:  
(10-19-2016 03:24 AM)Carlos295pz Wrote:  for CAS use a == 5

Good point. == and = are both relational operators. == is the actual test for equality. = works only in CAS and establishes an equation, which when used as an expression evaluates to true if and only if CAS can show that the left and right sides are the same.

<> and ≠ behave similarly.

A single = also works as a test for equality in non-CAS mode. Maybe it's not supposed to work but it does. Try it.

Code:
A:=5;
REPEAT
  PRINT(A);
  A:=A-1;
UNTIL A=0;
END;

Tom L

Tom L
I think therefore I am-Descartes
I think therefore you are-Gorgias
You're not here to think-Army Sergeant
Find all posts by this user
Quote this message in a reply
10-20-2016, 06:06 PM (This post was last modified: 10-20-2016 06:13 PM by compsystems.)
Post: #6
RE: [CAS] Detection of errors in the program editor
(CAS HPP-PL) Programming Language of the calculator HP-Prime CAS mode
PHP Code:
#cas
  
bbb():=
  
begin
    purge
(a);
    print (
5=6); wait
    print (
a=5); wait
    return 
"Done";
  
end;
#end 

->
5=6 //ok
a=5 //ok



the following statement the (CAS HPP-PL) compiler must detect the error
PHP Code:
...
  
purge(a);
  if( (
5) and truethen
  
... 
"Error: is not possible to determine the logical value of a = 5"
Find all posts by this user
Quote this message in a reply
10-20-2016, 07:39 PM
Post: #7
RE: [CAS] Detection of errors in the program editor
PHP Code:
5=6 o a=//Son ecuaciones permitidas por CAS 
PHP Code:
a=AND true //Error, ecuación AND lógico no es compatible.
(a==5) AND true //Correcto 

El operador relacional de igualdad en HOME puede ser = o ==, pero en CAS es distinto, en CAS el = se usa para definir ecuaciones de acuerdo a su contexto, se debe usar == para obtener un resultado relacional como true o false.

Viga C | TD | FB
Visit this user's website Find all posts by this user
Quote this message in a reply
10-20-2016, 08:05 PM
Post: #8
RE: [CAS] Detection of errors in the program editor
(10-20-2016 06:06 PM)compsystems Wrote:  the following statement the (CAS HPP-PL) compiler must detect the error
...
"Error: is not possible to determine the logical value of a = 5"

Why?

I can perfectly well determine if that is true or not. If a is not equal to 5, then it is false...

TW

Although I work for the HP calculator group, the views and opinions I post here are my own.
Find all posts by this user
Quote this message in a reply
10-20-2016, 08:17 PM (This post was last modified: 10-20-2016 08:19 PM by compsystems.)
Post: #9
RE: [CAS] Detection of errors in the program editor
(10-20-2016 07:39 PM)Carlos295pz Wrote:  
PHP Code:
5=6 o a=//Son ecuaciones permitidas por CAS 
PHP Code:
a=AND true //Error, ecuación AND lógico no es compatible.
(a==5) AND true //Correcto 

El operador relacional de igualdad en HOME puede ser = o ==, pero en CAS es distinto, en CAS el = se usa para definir ecuaciones de acuerdo a su contexto, se debe usar == para obtener un resultado relacional como true o false.
pero que pasa si me equivoco al digitar, el lugar de DOBLE IGUAL coloco un SOLO IGUAL dentro de un codigo CAS, el compilador no detecta esto. un código que estoy realizando me llevo mucho tiempo descubrir el problema, Insisto que hay problema en el compilador o no? ademas el signo igual tampoco es asignación, el operador asignación es :=

In the next case if it detects the error in the statement "if( a and true) then" when run program
PHP Code:
#cas
  
test( ):=
begin
  
print;
  
// ..
  
purge(a);
  if( 
and truethen
    
print("yes");
  else
    print(
"no");
  
end;

  return 
"Done";
end;
#end 

"Ifte: Unable to check test Error: Bad Argument Value"

It displays a message but should go to the code to show the line where occurred
Find all posts by this user
Quote this message in a reply
10-20-2016, 08:22 PM
Post: #10
RE: [CAS] Detection of errors in the program editor
(10-20-2016 08:05 PM)Tim Wessman Wrote:  
(10-20-2016 06:06 PM)compsystems Wrote:  the following statement the (CAS HPP-PL) compiler must detect the error
...
"Error: is not possible to determine the logical value of a = 5"

Why?

I can perfectly well determine if that is true or not. If a is not equal to 5, then it is false...


if 'a' is not defined I can not say anything
purge(a); 'a' not contain any object

a=5,It is indeterminate and no false
Find all posts by this user
Quote this message in a reply
10-20-2016, 10:30 PM (This post was last modified: 10-20-2016 10:34 PM by Carlos295pz.)
Post: #11
RE: [CAS] Detection of errors in the program editor
(10-20-2016 08:17 PM)compsystems Wrote:  ... Insisto que hay problema en el compilador o no? ademas el signo igual tampoco es asignación, el operador asignación es := ...
1. Creo que sería confuso identificar al compilar CAS diferentes funcionalidades del signo "=", en CAS esta orientado netamente al método algebraico, para definir ecuacines.
2. Recordar que el CAS de prime, esta basado en el programa Xcas, por lo que tratan de seguir fielmente su sintaxis.
3. En CAS la asignación se realiza solo con ":=" o "▶", sólo en HOME es donde se puede usar como asignación en las líneas de declaración de variables (LOCAL Var1=5, Var2=10; ), en el resto de líneas se debe usar ":=".

(10-20-2016 08:17 PM)compsystems Wrote:  In the next case if it detects the error in the statement "if( a and true) then" when run program...
1. (a and true), esto es correcto, porque de acuerdo al contenido de "a", de ser diferente de 0, será asumido como verdadero, por lo que no existiría error de sintaxis [valor_lógico and valor_lógico].
2. Caso distinto es ( a=5 and true) //Error

Viga C | TD | FB
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




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