{"id":294,"date":"2015-02-22T11:16:26","date_gmt":"2015-02-22T11:16:26","guid":{"rendered":"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdoc\/?page_id=294"},"modified":"2017-12-08T10:48:03","modified_gmt":"2017-12-08T10:48:03","slug":"operators","status":"publish","type":"page","link":"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdoc\/?page_id=294","title":{"rendered":"Operators"},"content":{"rendered":"<p>Each operator is given with its signature, consisting of a list of allowed typings, tried in order.<br \/>\nA typing is of the form <em>type<sub>1<\/sub><\/em>, &#8230;, <em>type<sub>n<\/sub><\/em> \u2192 <em>return-type<\/em>.<\/p>\n<h3>Arithmetic<\/h3>\n<ul>\n<li><strong>addition, concatenation<\/strong>:\n<ul>\n<li><code>+ : int, int \u2192 int<\/code><\/li>\n<li><code>+ : uint, uint \u2192 uint<\/code><\/li>\n<li><code>+ : float, float \u2192 float<\/code><\/li>\n<li><code>+ : ctime, ctime \u2192 ctime<\/code><\/li>\n<li><code>+ : ctime, int \u2192 ctime<\/code><\/li>\n<li><code>+ : ctime, timeval \u2192 timeval<\/code><\/li>\n<li><code>+ : timeval, int \u2192 timeval<\/code><\/li>\n<li><code>+ : timeval, ctime \u2192 timeval<\/code><\/li>\n<li><code>+ : timeval, timeval \u2192 timeval<\/code><br \/>\nNote: all of the above forms implement <em>truncated<\/em> addition, not addition modulo 2<em><sup>N<\/sup><\/em> for any <em>N<\/em>. This is done so that addition is monotonic in its arguments.<\/li>\n<li><code>+ : str, str \u2192 str<\/code> (string concatenation)<\/li>\n<li><code>+ : db[<\/code><em>type<\/em><sub>1<\/sub>, &#8230;, <em>type<sub>n<\/sub><\/em><code>], db[<\/code><em>type<\/em><sub>1<\/sub>, &#8230;, <em>type<sub>n<\/sub><\/em><code>] \u2192 db[<\/code><em>type<\/em><sub>1<\/sub>, &#8230;, <em>type<sub>n<\/sub><\/em><code>]<\/code><\/li>\n<li><code>+ : db[*], db[<\/code><em>type<\/em><sub>1<\/sub>, &#8230;, <em>type<sub>n<\/sub><\/em><code>] \u2192 db[<\/code><em>type<\/em><sub>1<\/sub>, &#8230;, <em>type<sub>n<\/sub><\/em><code>]<\/code><\/li>\n<li><code>+ : db[<\/code><em>type<\/em><sub>1<\/sub>, &#8230;, <em>type<sub>n<\/sub><\/em><code>], db[*] \u2192 db[<\/code><em>type<\/em><sub>1<\/sub>, &#8230;, <em>type<sub>n<\/sub><\/em><code>]<\/code><\/li>\n<li><code>+ : db[*], db[*] \u2192 db[*]<\/code><br \/>\n(database union)<br \/>\nNote: the two input database types must be identical, or at least one of them is the special type <code>db[*]<\/code> that only the empty database can have..<\/li>\n<\/ul>\n<\/li>\n<li><strong>subtraction<\/strong>:\n<ul>\n<li><code>- : int, int \u2192 int<\/code><\/li>\n<li><code>- : uint, uint \u2192 uint<\/code><\/li>\n<li><code>- : float, float \u2192 float<\/code><\/li>\n<li><code>- : ctime, ctime \u2192 ctime<\/code><\/li>\n<li><code>- : ctime, int \u2192 ctime<\/code><\/li>\n<li><code>- : timeval, int \u2192 timeval<\/code><\/li>\n<li><code>- : timeval, ctime \u2192 timeval<\/code><\/li>\n<li><code>- : timeval, timeval \u2192 timeval<\/code><br \/>\nNote: all of the above forms implement <em>truncated<\/em> subtraction, not subtraction modulo 2<em><sup>N<\/sup><\/em> for any <em>N<\/em>. This is done so that subtraction is monotonic in its first argument, and antitonic in its second argument.<\/li>\n<li><code>- : db[<\/code><em>type<\/em><sub>1<\/sub>, &#8230;, <em>type<sub>n<\/sub><\/em><code>], db[<\/code><em>type<\/em><sub>1<\/sub>, &#8230;, <em>type<sub>n<\/sub><\/em><code>] \u2192 db[<\/code><em>type<\/em><sub>1<\/sub>, &#8230;, <em>type<sub>n<\/sub><\/em><code>]<\/code><\/li>\n<li><code>- : db[*], db[<\/code><em>type<\/em><sub>1<\/sub>, &#8230;, <em>type<sub>n<\/sub><\/em><code>] \u2192 db[*]<\/code><\/li>\n<li><code>- : db[<\/code><em>type<\/em><sub>1<\/sub>, &#8230;, <em>type<sub>n<\/sub><\/em><code>], db[*] \u2192 db[<\/code><em>type<\/em><sub>1<\/sub>, &#8230;, <em>type<sub>n<\/sub><\/em><code>]<\/code><\/li>\n<li><code>- : db[*], db[*] \u2192 db[*]<\/code><br \/>\n(database difference)<br \/>\nNote: the two input database types must be identical, or at least one of them is the special type <code>db[*]<\/code> that only the empty database can have.<br \/>\nComputes first database without all the tuples of the second database.<\/li>\n<\/ul>\n<\/li>\n<li><strong>opposite<\/strong>:\n<ul>\n<li><code>- : int \u2192 int<\/code><br \/>\nNote: the above form implements <em>truncated<\/em> opposite, not opposite modulo 2<em><sup>N<\/sup><\/em> for any <em>N<\/em>. This is done so that opposite is monotonic in its argument. The only surprising case is taking the opposite of the least possible int (-2<em><sup>N-1<\/sup><\/em>, where <em>N<\/em> is the bit size), which yields the largest possible int (2<em><sup>N-1<\/sup><\/em>-1) instead of the modulo value, -2<em><sup>N<\/sup><\/em>.<\/li>\n<li><code>- : uint \u2192 int<\/code><br \/>\nAgain, this is truncated opposite.<\/li>\n<li><code>- : float \u2192 float<\/code><\/li>\n<\/ul>\n<\/li>\n<li><strong>same sign conversion<\/strong>:\n<ul>\n<li><code>+ : int \u2192 int<\/code><br \/>\nThe identity map.<\/li>\n<li><code>+ : uint \u2192 int<\/code><br \/>\nConversion from unsigned to signed integer. This is <em>truncated<\/em> conversion, not conversion module 2<em><sup>N<\/sup><\/em> for any <em>N<\/em>. This is done so as to be monotonic in its argument. Any number strictly greater than <code>-LONG_MIN<\/code> is converted to <code>LONG_MIN<\/code><\/li>\n<li><code>+ : float \u2192 float<\/code><br \/>\nThe identity map.<\/li>\n<\/ul>\n<\/li>\n<li><strong>multiplication<\/strong>:\n<ul>\n<li><code>* : int, int \u2192 int<\/code><\/li>\n<li><code>* : uint, uint \u2192 uint<\/code><br \/>\nNote: the above forms implement multiplication modulo word size, and are not monotonic.<\/li>\n<li><code>* : float, float \u2192 float<\/code><\/li>\n<\/ul>\n<\/li>\n<li><strong>division<\/strong>:\n<ul>\n<li><code>\/ : int, int \u2192 int<\/code> (quotient)<\/li>\n<li><code>\/ : uint, uint \u2192 uint<\/code> (quotient)<br \/>\nNote: the above forms implement multiplication modulo word size, and are not monotonic.<\/li>\n<li><code>\/ : float, float \u2192 float<\/code> (division)<\/li>\n<\/ul>\n<\/li>\n<li><strong>modulo<\/strong>:\n<ul>\n<li><code>% : int, int \u2192 int<\/code><\/li>\n<li><code>% : uint, uint \u2192 uint<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>Bitwise logic<\/h3>\n<ul>\n<li><strong>bitwise and<\/strong>:\n<ul>\n<li><code>&amp; : <\/code><em>type<sub>1<\/sub><\/em><code>, <\/code><em>type<sub>2<\/sub><\/em> <code>\u2192 <em>type<sub>1<\/sub><\/em><\/code><br \/>\nwhere <em>type<sub>1<\/sub><\/em>, <em>type<sub>2<\/sub><\/em> are any types among <code>int<\/code>, <code>uint<\/code>, <code>ipv4<\/code>.<\/li>\n<li><code>&amp; : ipv6, ipv6 \u2192 ipv6<\/code><\/li>\n<\/ul>\n<\/li>\n<li><strong>bitwise or<\/strong>:\n<ul>\n<li><code>| : <\/code><em>type<sub>1<\/sub><\/em><code>, <\/code><em>type<sub>2<\/sub><\/em> <code>\u2192 <em>type<sub>1<\/sub><\/em><\/code><br \/>\nwhere <em>type<sub>1<\/sub><\/em>, <em>type<sub>2<\/sub><\/em> are any types among <code>int<\/code>, <code>uint<\/code>, <code>ipv4<\/code>.<\/li>\n<li><code>| : ipv6, ipv6 \u2192 ipv6<\/code><\/li>\n<\/ul>\n<\/li>\n<li><strong>bitwise exclusive or<\/strong>:\n<ul>\n<li><code>^ : <\/code><em>type<sub>1<\/sub><\/em><code>, <\/code><em>type<sub>2<\/sub><\/em> <code>\u2192 <em>type<sub>1<\/sub><\/em><\/code><br \/>\nwhere <em>type<sub>1<\/sub><\/em>, <em>type<sub>2<\/sub><\/em> are any types among <code>int<\/code>, <code>uint<\/code>, <code>ipv4<\/code>.<\/li>\n<li><code>^ : ipv6, ipv6 \u2192 ipv6<\/code><\/li>\n<\/ul>\n<\/li>\n<li><strong>bitwise not<\/strong>:\n<ul>\n<li><code>~ : int \u2192 int<\/code><\/li>\n<li><code>~ : int \u2192 int<\/code><\/li>\n<li><code>~ : ipv4 \u2192 ipv4<\/code><\/li>\n<li><code>~ : ipv6 \u2192 ipv6<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>Logic<\/h3>\n<p>As in C, <code>int<\/code> is equated with the type of booleans, 0 is false, everything else is true.<\/p>\n<ul>\n<li><strong>logical and<\/strong>:\n<ul>\n<li><code>&amp;&amp; : int, int \u2192 int<\/code><\/li>\n<\/ul>\n<\/li>\n<li><strong>logical or<\/strong>:\n<ul>\n<li><code>|| : int, int \u2192 int<\/code><\/li>\n<\/ul>\n<\/li>\n<li><strong>logical negation<\/strong>:\n<ul>\n<li><code>! : int \u2192 int<\/code><\/li>\n<\/ul>\n<\/li>\n<li><strong>equality<\/strong>:\n<ul>\n<li><code>== : <em>type<\/em>, <em>type<\/em> \u2192 int<\/code><\/li>\n<li><code>!= : <em>type<\/em>, <em>type<\/em> \u2192 int<\/code><\/li>\n<\/ul>\n<p>where <em>type<\/em> is any type among <code>int<\/code>, <code>uint<\/code>, <code>float<\/code>, <code>str<\/code>, <code>ctime<\/code>, <code>timeval<\/code>, <code>ipv4<\/code>, <code>ipv6<\/code>, or a database type <code>db[<\/code><em>type<\/em><sub>1<\/sub>, &#8230;, <em>type<sub>n<\/sub><\/em><code>]<\/code>;<br \/>\nnote that the two arguments must be of the same type\u2014an exception is given by the following typing rules, which apply to the very special case of comparisons with the empty database<\/p>\n<ul>\n<li><code>==<\/code>,\u00a0<code>!= : db[*], db[<\/code><em>type<\/em><sub>1<\/sub>, &#8230;, <em>type<sub>n<\/sub><\/em><code>] \u2192 int<\/code><\/li>\n<li><code>==<\/code>, <code>!<\/code><code>=<\/code><code> : db[<\/code><em>type<\/em><sub>1<\/sub>, &#8230;, <em>type<sub>n<\/sub><\/em><code>], db[*] \u2192 int<\/code><\/li>\n<li><code>==<\/code>, <code>!=<\/code><code> : db[*], db[*] \u2192 int<\/code><\/li>\n<\/ul>\n<\/li>\n<li><strong>order<\/strong>:\n<ul>\n<li><code>&lt;= : <em>type<\/em>, <em>type<\/em> \u2192 int<\/code><\/li>\n<li><code>&lt; : <em>type<\/em>, <em>type<\/em> \u2192 int<\/code><\/li>\n<li><code>&gt;= : <em>type<\/em>, <em>type<\/em> \u2192 int<\/code><\/li>\n<li><code>&gt; : <em>type<\/em>, <em>type<\/em> \u2192 int<\/code><\/li>\n<\/ul>\n<p>where <em>type<\/em> is any type among <code>int<\/code>, <code>uint<\/code>, <code>float<\/code>, <code>str<\/code>, <code>ctime<\/code>, <code>timeval<\/code>, <code>ipv4<\/code>, <code>ipv6<\/code>, or a database type <code>db[*]<\/code> or\u00a0<code>db[<\/code><em>type<\/em><sub>1<\/sub>, &#8230;, <em>type<sub>n<\/sub><\/em><code>]<\/code> (databases are compared for inclusion); the ordering is:<\/p>\n<ul>\n<li>the natural ordering on data of types <code>int<\/code>, <code>uint<\/code>, <code>float<\/code>, <code>ctime<\/code>, <code>timeval<\/code>,<\/li>\n<li>the lexicographic ordering on strings (of type <code>str<\/code>), seen as byte strings\u2014not any fancier ordering such as UTF8 collation order: that may come, but no field of type <code>str<\/code> is currently flagged as monotonic anyway;<\/li>\n<li><code>ipv4<\/code> addresses are compared as though they were unsigned 32-bit integers;<\/li>\n<li><code>ipv6<\/code> addresses are compared lexicographically, considering they are 16-byte strings;<\/li>\n<li>databases, of type <code>db[*]<\/code> or <code>db[<\/code><em>type<\/em><sub>1<\/sub><code>,<\/code> &#8230;<code>,<\/code> <em>type<sub>n<\/sub><\/em><code>]<\/code>, are compared for inclusion.<\/li>\n<\/ul>\n<p>Note that the two arguments must be of the same type\u2014an exception is given by the following typing rules, which apply to the very special case of comparisons with the empty database<\/p>\n<ul>\n<li><code>&lt;=<\/code>, <code>&lt;<\/code>, <code>&gt;=<\/code>, <code>&gt; : db[*], db[<\/code><em>type<\/em><sub>1<\/sub>, &#8230;, <em>type<sub>n<\/sub><\/em><code>] \u2192 int<\/code><\/li>\n<li><code>&lt;=<\/code>, <code>&lt;<\/code>, <code>&gt;=<\/code>, <code>&gt; : db[<\/code><em>type<\/em><sub>1<\/sub>, &#8230;, <em>type<sub>n<\/sub><\/em><code>], db[*] \u2192 int<\/code><\/li>\n<li><code>&lt;=<\/code>, <code>&lt;<\/code>, <code>&gt;=<\/code>, <code>&gt; : db[*], db[*] \u2192 int<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ul>\n<li><strong>regexp matching<\/strong>:\n<ul>\n<li><code>=~ : str, regex \u2192 int<\/code><br \/>\nreturn true if string matches regexp<\/li>\n<li><code>!~ : str, regex \u2192 int<\/code><br \/>\nreturn true if string does not match regexp<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Each operator is given with its signature, consisting of a list of allowed typings, tried in order. A typing is of the form type1, &#8230;, typen \u2192 return-type. Arithmetic addition, concatenation: + : int, int \u2192 int + : uint, uint \u2192 uint + : float, float \u2192 float + : ctime, ctime \u2192 ctime &hellip; <a href=\"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdoc\/?page_id=294\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Operators<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"open","template":"","meta":{"footnotes":""},"class_list":["post-294","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdoc\/index.php?rest_route=\/wp\/v2\/pages\/294","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdoc\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdoc\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdoc\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdoc\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=294"}],"version-history":[{"count":12,"href":"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdoc\/index.php?rest_route=\/wp\/v2\/pages\/294\/revisions"}],"predecessor-version":[{"id":723,"href":"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdoc\/index.php?rest_route=\/wp\/v2\/pages\/294\/revisions\/723"}],"wp:attachment":[{"href":"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdoc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=294"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}