Not (SelectionCriterion function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
Line 1: Line 1:
<span style="font-size:120%; color:black"><b>Create selection expression that is a logical negation</b></span>
{{Template:SelectionCriterion:Not subtitle}}
[[Category:SelectionCriterion methods|NOT constructor]]
<!--DPL?? Category:SelectionCriterion methods|NOT constructor: Create selection expression that is a logical negation-->
<!--DPL?? Category:System methods|NOT (SelectionCriterion constructor): Create selection expression that is a logical negation-->
<p>
NOT is a member of the [[SelectionCriterion class]].
</p>


This shared method creates a new SelectionCriterion object
This shared method creates a new <var>SelectionCriterion</var> object
that is a logical negation of its SelectionCriterion parameter.
that is a logical negation of its <var>SelectionCriterion</var> parameter.
A NOT criterion returns true for a collection item if NOT's
A <var>Not</var> criterion returns true for a collection item if <var>Not</var>'s
component SelectionCriterion expression is false for the item;
component <var>SelectionCriterion</var> expression is false for the item;
otherwise it returns true.
otherwise it returns true.


The collection searching method ([[??]] refid=srchcol.)
The [[Collections#Searching a collection|collection searching method]]
that makes use of this selection criterion specifies:
that makes use of this <var>SelectionCriterion</var> specifies:
<ul>
<ul>
<li>Whether to return the first item or item number or all items that satisfy the
<li>Whether to return the first item or item number or all items that satisfy the
Line 20: Line 14:
<li>Where in the collection to begin searching.
<li>Where in the collection to begin searching.
</ul>
</ul>
===Syntax===
==Syntax==
  %selc = [%(selectionCriterion for itemtype):]  -
{{Template:SelectionCriterion:Not syntax}}
            NOT(criterion)
 
===Syntax terms===
===Syntax terms===
<dl>
<table class="syntaxTable">
<dt><i>%selc</i>
<tr><th>%selectionCriterion</th>
<dd>A SelectionCriterion object variable to contain the new object instance.
<td>A <var>SelectionCriterion</var> object variable to contain the new object instance. </td></tr>
<dt><i>%(selectionCriterion for itemtype)</i>
<dt><i>%(selectionCriterion for itemtype)</i>
<dd>This optional specification of the class and collection item type
<dd>This optional specification of the class and collection item type
in parentheses indicates
in parentheses indicates
that the method is shared and does not operate on a specific instance.
that the method is shared and does not operate on a specific instance.
<dt><i>criterion</i>
<tr><th>criterion</th>
<dd>A SelectionCriterion object.
<td>A SelectionCriterion object. </td></tr>
</table>


</dl>
==Usage Notes==
===Usage Notes===


The NOT constructor is '''never''' necessary, and anything you can
The <var>Not</var> constructor is '''never''' necessary, and anything you can
do with the NOT can be done (probably more clearly) otherwise.
do with the <var>Not</var> can be done (probably more clearly) otherwise.
For example, the following two criteria are identical:
For example, the following two criteria are identical:
<pre>
<p class="code">
    %sel = not(gt(this(90))
%sel = not(gt(this(90))


    %sel = le(this(90))
%sel = le(this(90))
</pre>
</p>


And the following two criteria are identical:
And the following two criteria are identical:
<pre>
<p class="code">%sel = not(or(lt(this,70), ge(this,95)))
    %sel = not(or(lt(this,70), ge(this,95)))


    %sel = and(ge(this,70), lt(this,95))
%sel = and(ge(this,70), lt(this,95))
</pre>
</p>


And these criteria are identical:
And these criteria are identical:
<pre>
<p class="code">%sel = not(true)
    %sel = not(true)
 
%sel = false
</p>


    %sel = false
Internally, <var>Not</var>s are always converted to the inverse of the parameter criterion.
</pre>
==See also==
{{Template:SelectionCriterion:Not footer}}


Internally, NOTs are always converted to the inverse of the parameter criterion.
[[Category:SelectionCriterion methods]]

Revision as of 19:54, 24 June 2011

Matches an item if it does not meet the criterion (SelectionCriterion class)


This shared method creates a new SelectionCriterion object that is a logical negation of its SelectionCriterion parameter. A Not criterion returns true for a collection item if Not's component SelectionCriterion expression is false for the item; otherwise it returns true.

The collection searching method that makes use of this SelectionCriterion specifies:

  • Whether to return the first item or item number or all items that satisfy the selection criterion.
  • Where in the collection to begin searching.

Syntax

%selectionCriterion = [%(SelectionCriterion For itemType):]Not( selectionCriterion)

Syntax terms

%(selectionCriterion for itemtype)
This optional specification of the class and collection item type in parentheses indicates that the method is shared and does not operate on a specific instance.
%selectionCriterion A SelectionCriterion object variable to contain the new object instance.
criterion A SelectionCriterion object.

Usage Notes

The Not constructor is never necessary, and anything you can do with the Not can be done (probably more clearly) otherwise. For example, the following two criteria are identical:

%sel = not(gt(this(90)) %sel = le(this(90))

And the following two criteria are identical:

%sel = not(or(lt(this,70), ge(this,95))) %sel = and(ge(this,70), lt(this,95))

And these criteria are identical:

%sel = not(true) %sel = false

Internally, Nots are always converted to the inverse of the parameter criterion.

See also