Skip to content

Commit c3fd077

Browse files
committed
removes inconsistencies in how the cardinality of a sequence/list is denoted
1 parent ae554d5 commit c3fd077

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

spec/index.html

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9474,9 +9474,10 @@ <h4>Aggregate Algebra</h4>
94749474
</ol>
94759475

94769476
<p><b>Special Case:</b> when <code>COUNT</code> is used with the expression
9477-
<code>*</code> the value of F will be the cardinality of the group solution sequence,
9478-
<code>card[Ψ]</code>, or <code>card[Dedup(Ψ)]</code> if the <code>DISTINCT</code>
9479-
keyword is present.</p>
9477+
<code>*</code>, then F(Ψ) is the cardinality of the group solution sequence,
9478+
i.e., F(Ψ)&nbsp;=&nbsp;<a href="#defn_Card">Card</a>(Ψ),
9479+
or F(Ψ)&nbsp;=&nbsp;<a href="#defn_Card">Card</a>(Dedup(Ψ))
9480+
if the <code>DISTINCT</code> keyword is present.</p>
94809481
</div>
94819482
<p><i>scalarvals</i> are used to pass values to the underlying set function, bypassing
94829483
the mechanics of the grouping. For example, the aggregate expression
@@ -9537,6 +9538,11 @@ <h4>Aggregate Algebra</h4>
95379538
<p>The Flatten(S) function takes a sequence of lists, S = [(L<sub>1</sub>, L<sub>2</sub>,
95389539
...), ...], and returns the list ( x | L in S and x in L ).</p>
95399540
</div>
9541+
<p>Card is a function that returns the cardinality of a sequence or a list of elements (which may be solution mappings or other types of elements, depending on the context).
9542+
<div class="defn">
9543+
<p><b>Definition: <span id="defn_Card">Card</span></b></p>
9544+
<p>Given a sequence or a list |L|, Card(|L|) is the cardinality of |L|.</p>
9545+
</div>
95409546
<section id="setFunctions">
95419547
<h5>Set Functions</h5>
95429548
<p>The set functions which underlie SPARQL aggregates all have a common signature:
@@ -9568,7 +9574,7 @@ <h5>Count</h5>
95689574
<pre class="code nohighlight">xsd:integer Count(sequence S)</pre>
95699575
<p>L = Flatten(S)</p>
95709576
<p>remove error elements from L</p>
9571-
<p>Count(S) = card[L]</p>
9577+
<p>Count(S) = <a href="#defn_Card">Card</a>(L)</p>
95729578
</div>
95739579
</section>
95749580
<section id="aggSum">
@@ -9583,10 +9589,10 @@ <h5>Sum</h5>
95839589
<pre class="code nohighlight">numeric Sum(sequence S)</pre>
95849590
<p>L = Flatten(S)</p>
95859591
<p>Sum(S) = Sum(L)</p>
9586-
<p>Sum(L) = op:numeric-add(L<sub>1</sub>, Sum(L<sub>2..n</sub>)) when card[L] &gt;
9592+
<p>Sum(L) = op:numeric-add(L<sub>1</sub>, Sum(L<sub>2..n</sub>)) when <a href="#defn_Card">Card</a>(L) &gt;
95879593
1<br>
9588-
Sum(L) = op:numeric-add(L<sub>1</sub>, 0) when card[L] = 1<br>
9589-
Sum(L) = "0"^^xsd:integer when card[L] = 0</p>
9594+
Sum(L) = op:numeric-add(L<sub>1</sub>, 0) when <a href="#defn_Card">Card</a>(L) = 1<br>
9595+
Sum(L) = "0"^^xsd:integer when <a href="#defn_Card">Card</a>(L) = 0</p>
95909596
<p>In this way, Sum( (1, 2, 3) ) = op:numeric-add(1, op:numeric-add(2,
95919597
op:numeric-add(3, 0))).</p>
95929598
</div>
@@ -9615,8 +9621,8 @@ <h5>Min</h5>
96159621
<p>L = Flatten(S)</p>
96169622
<p>Min(S) = Min(L)</p>
96179623
<p>The flattened list L of values is ordered as per the <code>ORDER BY ASC</code> clause.</p>
9618-
<p>Min(L) = L<sub>0</sub> if card[L] > 0<br>
9619-
Min(L) = error if card[L] = 0</p>
9624+
<p>Min(L) = L<sub>0</sub> if <a href="#defn_Card">Card</a>(L) > 0<br>
9625+
Min(L) = error if <a href="#defn_Card">Card</a>(L) = 0</p>
96209626
</div>
96219627
</section>
96229628
<section id="aggMax">
@@ -9631,8 +9637,8 @@ <h5>Max</h5>
96319637
<p>L = Flatten(S)</p>
96329638
<p>Max(S) = Max(L)</p>
96339639
<p>The flattened list L of values is ordered as per the <code>ORDER BY DESC</code> clause.</p>
9634-
<p>Max(L) = L<sub>0</sub> if card[L] > 0<br>
9635-
Max(L) = error if card[L] = 0</p>
9640+
<p>Max(L) = L<sub>0</sub> if <a href="#defn_Card">Card</a>(L) > 0<br>
9641+
Max(L) = error if <a href="#defn_Card">Card</a>(L) = 0</p>
96369642
</div>
96379643
</section>
96389644
<section id="aggGroupConcat">
@@ -9648,12 +9654,11 @@ <h5>GroupConcat</h5>
96489654
be the "space" character, unicode codepoint U+0020.</p>
96499655
<p>L = Flatten(S)</p>
96509656
<p>GroupConcat(S, scalarvals) = GroupConcat(L, scalarvals("separator"))</p>
9651-
<p>GroupConcat(L, sep) = "", where <span style=
9652-
"font-size: 140%">|</span>L<span style="font-size: 140%">|</span> = 0</p>
9657+
<p>GroupConcat(L, sep) = "", where <a href="#defn_Card">Card</a>(L) = 0</p>
96539658
<p>GroupConcat(L, sep) = CONCAT("", L<sub>0</sub>), where
9654-
<span style="font-size: 140%">|</span>L<span style="font-size: 140%">|</span> = 1</p>
9659+
<a href="#defn_Card">Card</a>(L) = 1</p>
96559660
<p>GroupConcat(L, sep) = CONCAT(L<sub>0</sub>, sep, GroupConcat(L<sub>1..n-1</sub>,
9656-
sep)), where <span style="font-size: 140%">|</span>L<span style="font-size: 140%">|</span> &gt; 1</p>
9661+
sep)), where <a href="#defn_Card">Card</a>(L) &gt; 1</p>
96579662
</div>
96589663
<p>For example, GroupConcat([("a"), ("b"), ("c")], {"separator" → "."}) = "a.b.c".</p>
96599664
</section>

0 commit comments

Comments
 (0)