<?xml version="1.0" encoding="utf-8" ?> <!-- for emacs: -*- coding: utf-8 -*- --> <!-- Apache may like this line in the file .htaccess: AddCharset utf-8 .html --> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg-flat.dtd" > <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head><title>precedence of operators</title> <link rel="stylesheet" type="text/css" href="../../../../Macaulay2/Style/doc.css"/> </head> <body> <table class="buttons"> <tr> <td><div><a href="_operator__Attributes.html">next</a> | <a href="__se.html">previous</a> | <a href="_operator__Attributes.html">forward</a> | <a href="__se.html">backward</a> | <a href="_operators.html">up</a> | <a href="index.html">top</a> | <a href="master.html">index</a> | <a href="toc.html">toc</a> | <a href="http://www.math.uiuc.edu/Macaulay2/">Macaulay2 web site</a></div> </td> </tr> </table> <div><a href="index.html" title="">Macaulay2Doc</a> > <a href="___The_sp__Macaulay2_splanguage.html" title="">The Macaulay2 language</a> > <a href="_operators.html" title="">operators</a> > <a href="_precedence_spof_spoperators.html" title="">precedence of operators</a></div> <hr/> <div><h1>precedence of operators</h1> <div><p>One aspect of parsing precedence is associativity. A <em>left-associative</em> operator is one, such as <a href="__st.html" title="a binary operator, usually used for multiplication">*</a>, with the property that <tt>x * y * z</tt> is parsed as <tt>(x * y) * z</tt>. A <em>right-associative</em> operator is one, such as <a href="__eq.html" title="assignment">=</a>, with the property that <tt>x = y = z</tt> is parsed as <tt>x = (y = z)</tt>. These operators are left associative: <a href="__sh.html" title="length, or access to elements">#</a> <a href="__sh_qu.html" title="check for presence of elements">#?</a> <a href="__pc.html" title="a binary operator, usually used for remainder and reduction">%</a> <a href="__am.html" title="a binary operator">&</a> <a href="__st.html" title="a binary operator, usually used for multiplication">*</a> <a href="__st_st.html" title="a binary operator, usually used for tensor product or Cartesian product">**</a> <a href="__pl.html" title="a unary or binary operator, usually used for addition">+</a> <a href="__pl_pl.html" title="a binary operator, usually used for direct sum">++</a> <a href="__cm.html" title="the comma, used for separating entries in a list or sequence">,</a> <a href="_-.html" title="a unary or binary operator, usually used for negation or subtraction">-</a> <a href="_..html" title="access to elements whose key is a symbol">.</a> <a href="_...html" title="a binary operator, used for sequences of consecutive items">..</a> <a href="_.._lt.html" title="a binary operator, used for sequences of consecutive items, not including the endpoint">..<</a> <a href="_._qu.html" title="check for presence of elements whose key is a symbol">.?</a> <a href="__sl.html" title="a binary operator, usually used for division">/</a> <a href="__sl_sl.html" title="a binary operator, usually used for quotient">//</a> <a href="__lt_lt.html" title="a binary operator (file output, ...)"><<</a> <a href="__at_at.html" title="a binary operator">@@</a> <a href="_^.html" title="a binary operator, usually used for powers">^</a> <a href="_^_st_st.html" title="a binary operator, usually used for tensor or Cartesian power">^**</a> <a href="_^^.html" title="a binary operator">^^</a> <a href="__us.html" title="a binary operator, used for subscripting and access to elements">_</a> <a href="__vb.html" title="a binary operator, often used for horizontal concatenation">|</a> <a href="__vb_vb.html" title="a binary operator, often used for vertical concatenation">||</a>, and these operators are right associative: <a href="_!_eq.html" title="inequality">!=</a> <a href="_-_gt.html" title="make a function">-></a> <a href="__co.html" title="a binary operator, uses include repetition; ideal quotients">:</a> <a href="__co_eq.html" title="assignment of method or new local variable">:=</a> <a href="__se.html" title="statement separator">;</a> <a href="__lt.html" title="less than"><</a> <a href="__lt-.html" title="assignment with left side evaluated"><-</a> <a href="__lt_eq.html" title="less than or equal"><=</a> <a href="__lt_eq_eq.html" title="a unary and binary operator"><==</a> <a href="__lt_eq_eq_eq.html" title="a unary and binary operator"><===</a> <a href="__lt_eq_eq_gt.html" title="a binary operator"><==></a> <a href="__eq.html" title="assignment">=</a> <a href="__eq!_eq.html" title="strict inequality">=!=</a> <a href="__eq_eq.html" title="equality">==</a> <a href="___Thing_sp_eq_eq_eq_sp__Thing.html" title="strict equality">===</a> <a href="__eq_eq_eq_gt.html" title="a binary operator">===></a> <a href="__eq_eq_gt.html" title="a binary operator">==></a> <a href="__eq_gt.html" title="produce an Option">=></a> <a href="__gt.html" title="greater than">></a> <a href="__gt_eq.html" title="greater than or equal">>=</a> <a href="__gt_gt.html" title="a binary operator, uses include bit shifting, or attaching optional inputs to functions">>></a> <a href="__qu.html" title="comparison operator">?</a> <a href="__at.html" title="a binary operator">@</a> <a href="__bs.html" title="a binary operator">\</a> <a href="__bs_bs.html" title="a binary operator">\\</a> <a href="__vb-.html" title="a binary operator">|-</a> <a href="_and.html" title="conjunction">and</a> <a href="_or.html" title="disjunction">or</a> <a href="___S__P__A__C__E.html" title="blank operator; often used for function application, making polynomial rings">SPACE</a> .</p> <p>Here are the operators arranged in order of increasing parsing precedence. For example, <tt>*</tt> has higher parsing precedence than <tt>+</tt>, and hence <tt>2+3*5</tt> is parsed as though it had been written as <tt>2+(3*5)</tt>. The symbol <a href="___S__P__A__C__E.html" title="blank operator; often used for function application, making polynomial rings">SPACE</a> represents the operator that is used when two things are adjacent in program code.</p> <table class="examples"><tr><td><pre> 8 ; 10 , 14 -> := <- = => >> 18 << 20 |- 22 <=== ===> 24 <==> 26 <== ==> 28 or 30 and 32 not 34 != < <= =!= == === > >= ? 36 || 38 : 40 | 42 ^^ 44 & 46 .. ..< 48 + ++ - 50 ** 54 % * / // \ \\ 56 @ 58 SPACE 60 (*) 62 @@ 64 ^* _* ~ 66 # #? . .? ^ ^** _ 68 ! </pre> </td></tr> </table> </div> <div class="single"><h2>See also</h2> <ul><li><span><a href="_parsing_spprecedence_cm_spin_spdetail.html" title="">parsing precedence, in detail</a></span></li> </ul> </div> </div> </body> </html>