Post Reply 
Easy question
09-09-2021, 05:55 PM
Post: #13
RE: Easy question
(09-07-2021 01:09 AM)Albert Chan Wrote:  
(09-06-2021 10:31 PM)jte Wrote:  I thought I’d also try it using Python syntax in the CAS. There, “True or False and False” evaluates to “False”.

This showed CAS AND does not have higher precedence: 1+0×0 = 1
CAS only does left to right: (1+0)×0 = 0

Yes, or to be more explicit: this seems to be true (in the CAS) whether or not Python syntax is being used. The following function, defined using Python syntax, flows into (A / True) when using the Prime’s Python evaluator and into (B / False) when using the CAS with Python syntax.

Code:
def eval_test():
  if True or False and False:
    # (A / True)
  else:
    # (B / False)

My first test routine, eval_test2(), shown below, was actually to simply return the result of “True or False and False”, and then print it, but it seems there might be an issue with booleans in Python-syntax CAS functions on the Prime as eval_test2() returns “(null)” when run as a Python-syntax CAS function.

Code:
def eval_test2():
  return True or False and False

“On the Prime” as eval_test2() in Xcas (1.7.0-29), with “Xcas syntax” selected, returns “false”. (Well, Xcas did crash on me once, but I’m thinking that that could’ve been caused by my playing around with things like print_test() — print_test() reliably crashes both Xcas and the Prime CAS. [It is flagged as a syntax error when tried as Python, either in Xcas or in the Prime’s Python.] I’ll send in a bug report.)

Code:
def print_test():
  print "%s %s" % True or False and False, False
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Easy question - boggiano - 09-01-2021, 10:10 AM
RE: Easy question - roadrunner - 09-01-2021, 11:54 AM
RE: Easy question - rawi - 09-01-2021, 04:02 PM
RE: Easy question - toml_12953 - 09-01-2021, 04:11 PM
RE: Easy question - jte - 09-06-2021, 12:36 AM
RE: Easy question - Albert Chan - 09-06-2021, 01:17 AM
RE: Easy question - ijabbott - 09-06-2021, 12:41 PM
RE: Easy question - jte - 09-06-2021, 10:31 PM
RE: Easy question - Albert Chan - 09-07-2021, 01:09 AM
RE: Easy question - jte - 09-09-2021 05:55 PM
RE: Easy question - jte - 09-06-2021, 05:39 PM
RE: Easy question - boggiano - 09-09-2021, 10:44 AM
RE: Easy question - Joe Horn - 09-09-2021, 05:40 PM
RE: Easy question - boggiano - 09-09-2021, 06:05 PM
RE: Easy question - toml_12953 - 09-09-2021, 10:10 PM
RE: Easy question - boggiano - 09-09-2021, 10:32 PM
RE: Easy question - ijabbott - 09-09-2021, 11:59 PM
RE: Easy question - Albert Chan - 09-10-2021, 05:23 PM
RE: Easy question - ijabbott - 09-10-2021, 06:09 PM
RE: Easy question - boggiano - 09-11-2021, 12:16 AM
RE: Easy question - toml_12953 - 09-11-2021, 11:14 AM



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