Skip to content
Glen Low edited this page Dec 22, 2015 · 14 revisions
<tr>
  <th>Difference</th>
  <td><code>age.subtract(beauty)</code></td>
  <td><code>age MINUS beauty</code></td>
  <td><code>age - beauty</code></td>
</tr>

<tr>
  <th>Intersect</th>
  <td><code>age.intersect(beauty)</code></td>
  <td><code>age INTERSECT beauty</code></td>
  <td><code>age &amp; beauty</code></td>
</tr>

<tr>
  <th>Nullary Date</th>
  <td><code>NSDate()</code></td>
  <td colspan="2"><code>now()</code></td>
</tr>

<tr>
  <th>Nullary Integer</th>
  <td>N.A.</td>
  <td colspan="2"><code>random()</code></td>
</tr>

<tr>
  <th>Subquery</th>
  <td><code>age.filter{ $0 &gt; 42 }</code></td>
  <td><code>SUBQUERY(age, $x, $x &gt; 42)</code></td>
  <td><code>subquery(age, iterator: x, predicate: x &gt; 42)</code></td>
</tr>

<tr>
  <th rowspan="2">Unary Integer</th>
  <td>N.A.</td>
  <td colspan="2"><code>randomn(age)</code></td>
</tr>
<tr>
  <td colspan="3"><code>~age</code></td>
</tr>

<tr>
  <th rowspan="8">Unary Number</th>
  <td colspan="3"><code>sqrt(age)</code></td>
</tr>
<tr>
  <td colspan="3"><code>log(age)</code></td>
</tr>
<tr>
  <td colspan="3"><code>ln(age)</code></td>
</tr>
<tr>
  <td colspan="3"><code>exp(age)</code></td>
</tr>
<tr>
  <td colspan="3"><code>floor(age)</code></td>
</tr>
<tr>
  <td><code>ceil(age)</code></td>
  <td><code>ceiling(age)</code></td>
  <td><code>ceil(age)</code></td>
</tr>
<tr>
  <td colspan="3"><code>abs(age)</code></td>
</tr>
<tr>
  <td colspan="3"><code>trunc(age)</code></td>
</tr>

<tr>
  <th rowspan="8">Unary Sequence to Number</th>
  <td>age.reduce(0, combine:+)</td>
  <td colspan="2">sum(age)</td>
</tr>
<tr>
  <td>age.count</td>
  <td colspan="2">count(age)</td>
</tr>
<tr>
  <td>age.minElement()</td>
  <td colspan="2">min(age)</td>
</tr>
<tr>
  <td>age.maxElement()</td>
  <td colspan="2">max(age)</td>
</tr>
<tr>
  <td>N.A.</td>
  <td colspan="2">average(age)</td>
</tr>   
<tr>
  <td>N.A.</td>
  <td colspan="2">median(age)</td>
</tr>
<tr>
  <td>N.A.</td>
  <td colspan="2">mode(age)</td>
</tr>
<tr>
  <td>N.A.</td>
  <td colspan="2">stddev(age)</td>
</tr>

<tr>
  <th rowspan="2">Unary String</th>
  <td>age.lowercaseString</td>
  <td colspan="2">lowercase(age)</td>
</tr>
<tr>
  <td>age.uppercaseString</td>
  <td colspan="2">uppercase(age)</td>
</tr>

<tr>
  <th>Unary String to Integer</th>
  <td>age.length</td>
  <td colspan="2">length(age)</td>
</tr>

<tr>
  <th>Union</th>
  <td>age.union(beauty)</td>
  <td>age UNION beauty</td>
  <td>age | beauty</td>
</tr>

<tr>
  <th>And</th>
  <td>age &gt; 21 &amp;&amp; age &lt; 42</td>
  <td>age &gt; 21 AND age &lt; 42</td>
  <td>age &gt; 21 &amp;&amp; age &lt; 42</td>
</tr>

<tr>
  <th rowspan="6">Comparison</th>
  <td colspan="3">age &lt; 42</td>
</tr>
<tr>
  <td colspan="3">age &lt;= 42</td>
</tr>
<tr>
  <td colspan="3">age &gt; 42</td>
</tr>
<tr>
  <td colspan="3">age &gt;= 42</td>
</tr>
<tr>
  <td colspan="3">age == 42</td>
</tr>
<tr>
  <td colspan="3">age != 42</td>
</tr>

<tr>
  <th>Not</th>
  <td colspan="3">!(age &gt; 42)</td>
</tr>


<tr>
  <th>Or</th>
  <td>age &gt; 21 || age &lt; 42</td>
  <td>age &gt; 21 OR age &lt; 42</td>
  <td>age &gt; 21 || age &lt; 42</td>
</tr>

<tr>
  <th rowspan="2">Quantified</th>
  <td>N.A.</td>
  <td>ALL age == 42</td>
  <td>all(age == 42)</td>
</tr>

<tr>
  <td>N.A.</td>
  <td>ANY age == 42</td>
  <td>any(age == 42)</td>
</tr>
Swift NSPredicate PredicatePal
Terms N.A. ANYKEY AnyKey<T>
N.A. Block<T> { }
true TRUEPREDICATE Boolean(true)
false FALSEPREDICATE Boolean(false)
42 Const(42)
"hello" Const("hello")
self.age age Key<T>("age")
self SELF This<T>()
N.A. $age Var<T>("age")
Binary Index age[1]
age["one"]
Binary Integer age & 42
age | 42
age ^ 42
age << 42
age >> 42
Binary Location to Number age.distanceFromLocation
(beauty)
distanceToLocation:
fromLocation:
(age, beauty)
age - beauty
Binary Number age + 42
age - 42
age * 42
age / 4
age % 4 modulus:by:(age, 4) age % 4
pow(age, 4) age ** 4
Clone this wiki locally