1

In Mathematica, "or" looks to be defined with a double vertical bar. See https://reference.wolfram.com/language/ref/Or.html or https://mathematica.stackexchange.com/a/119763.

In Mathics 2.1.0, that doesn't seem to work:

In[16]:= If[1<0 || 2<3 || 3<4, 0, 1]
Syntax::sntxf: "If[1<0 " cannot be followed by " 2<3  3<4, 0, 1]" (line 1 of "<stdin>").

whereas the word "or" seems to work:

In[16]:= If[1<0 or 2<3 or 3<4, 0, 1]
Out[16]= 1

So do I have to use || in Mathematica and or in Mathics, or am I mistaken?

dfrankow
  • 20,191
  • 41
  • 152
  • 214

1 Answers1

0

Mathics has a documentation, though it's a pdf for some reason, https://mathics.org/docs/mathics-latest.pdf

Page 11 at the moment (part of 3. Language Tutorials):

Comparisons and Boolean Logic

[...]

Truth values can be negated using ! (logical not) and combined using && (logical and) and || (logical or):

>> !True
   False
>> !False
   True
>> 3 < 4 && 6 > 5
   True

&& has higher precedence than ||, i.e. it binds stronger:

>> True && True || False && False
   True
>> True && (True || False) && False
   False

based on that I would indeed expect || and && to work.

Also, there is an example on page 44 with If[x == 0.0 && y <= 0, 0.0, Sin[x ^ y] + 1 / Min[x, 0.5]] + 0.5].

Your error message may be the key here as the || became those boxed question marks, which may be something about character encoding. If it is a file you are running, it may be worth checking if it's ASCII.

tevemadar
  • 12,389
  • 3
  • 21
  • 49