Skip to content

Commit a8a7de9

Browse files
authored
Merge pull request github#2070 from shati-patel/hb/updates
Approved by jf205
2 parents 3313af5 + 9c54eef commit a8a7de9

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

docs/language/ql-handbook/expressions.rst

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -303,22 +303,22 @@ Let us apply these steps to the ``sum`` aggregate in the following query:
303303
.. code-block:: ql
304304
305305
select sum(int i, int j |
306-
exists(string char | char = "hello".charAt(i)) and exists(string char | char = "world!".charAt(j)) | i)
306+
exists(string s | s = "hello".charAt(i)) and exists(string s | s = "world!".charAt(j)) | i)
307307
308308
#. Input variables: ``i``, ``j``.
309309

310310
#. All possible tuples ``(<value of i>, <value of j>)`` satisfying the given condition:
311-
``(0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (1, 0), (1, 1),...,(4, 5)``.
311+
``(0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (1, 0), (1, 1), ..., (4, 5)``.
312312

313-
``30`` tuples are generated in this step.
313+
30 tuples are generated in this step.
314314

315315
#. Apply the ``<expression> i`` on all tuples. This means selecting all values of ``i`` from
316316
all tuples: ``0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4.``
317317

318318
#. Apply the aggregation function ``sum`` on the above values to get the final result ``60``.
319319

320-
If we change ``<expression>`` to ``i+j`` in the above query, the query result is ``135`` since
321-
applying ``i+j`` on all tuples results in following values: 
320+
If we change ``<expression>`` to ``i + j`` in the above query, the query result is ``135`` since
321+
applying ``i + j`` on all tuples results in following values: 
322322
\ ``0, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 2, 3, 4, 5, 6, 7, 3, 4, 5, 6, 7, 8, 4, 5, 6, 7, 8, 9``.
323323

324324
Next, consider the following query:
@@ -327,11 +327,15 @@ Next, consider the following query:
327327
328328
select count(string s | s = "hello" | s.charAt(_))
329329
330-
``s`` is the input variable of the aggregate. A single tuple ``("hello")`` is generated after
331-
applying step 2. When the ``<expression> charAt(_)`` is applied on this tuple, it generates ``4``
332-
distinct values ``'h', 'e', 'l', 'o'``. Note that ``'l'`` only appears once as this step collects
333-
the distinct values generated as a result of applying ``<expression>``. Finally, ``count`` is
334-
applied on these values, and the query returns ``4``.
330+
#. ``s`` is the input variable of the aggregate.
331+
332+
#. A single tuple ``"hello"`` is generated in this step.
333+
334+
#. The ``<expression> charAt(_)`` is applied on this tuple. The underscore ``_`` in ``charAt(_)``
335+
is a :ref:`don't-care expression <dont-care>`, which represents any value.
336+
``s.charAt(_)`` generates four distinct values ``h, e, l, o``.
337+
338+
#. Finally, ``count`` is applied on these values, and the query returns ``4``.
335339

336340

337341

0 commit comments

Comments
 (0)