Skip to content

Commit 986c15c

Browse files
authored
Update introduction-to-ql.rst
1 parent dded684 commit 986c15c

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

docs/codeql/writing-codeql-queries/introduction-to-ql.rst

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,39 +54,39 @@ Simple exercises
5454

5555
You can write simple queries using the some of the basic functions that are available for the ``int``, ``date``, ``float``, ``boolean`` and ``string`` types. To apply a function, append it to the argument. For example, ``1.toString()`` converts the value ``1`` to a string. Notice that as you start typing a function, a pop-up is displayed making it easy to select the function that you want. Also note that you can apply multiple functions in succession. For example, ``100.log().sqrt()`` first takes the natural logarithm of 100 and then computes the square root of the result.
5656

57-
Exercise 1
58-
~~~~~~~~~~
57+
Exercise 1 - Strings
58+
~~~~~~~~~~~~~~~~~~~~
5959

6060
Write a query which returns the length of the string ``"lgtm"``. (Hint: `here <https://codeql.github.com/docs/ql-language-reference/ql-language-specification/#built-ins-for-string>`__ is the list of the functions that can be applied to strings.)
6161

62-
➤ `Check your answer <#answer:-exercise-1>`__
62+
➤ `Check your answer <#exercise-1>`__
6363

6464
There is often more than one way to define a query. For example, we can also write the above query in the shorter form:
6565

6666
.. code-block:: ql
6767
6868
select "lgtm".length()
6969
70-
Exercise 2
71-
~~~~~~~~~~
70+
Exercise 2 - Numbers
71+
~~~~~~~~~~~~~~~~~~~~
7272

7373
Write a query which returns the sine of the minimum of ``3^5`` (``3`` raised to the power ``5``) and ``245.6``.
7474

75-
➤ `Check your answer <#answer:-exercise-2>`__
75+
➤ `Check your answer <#exercise-2>`__
7676

77-
Exercise 3
78-
~~~~~~~~~~
77+
Exercise 3 - Booleans
78+
~~~~~~~~~~~~~~~~~~~~~
7979

8080
Write a query which returns the opposite of the boolean ``false``.
8181

82-
➤ `Check your answer <#answer:-exercise-3>`__
82+
➤ `Check your answer <#exercise-3>`__
8383

84-
Exercise 4
85-
~~~~~~~~~~
84+
Exercise 4 - Dates
85+
~~~~~~~~~~~~~~~~~~
8686

8787
Write a query which computes the number of days between June 10 and September 28, 2017.
8888

89-
➤ `Check your answer <#answer:-exercise-4>`__
89+
➤ `Check your answer <#exercise-4>`__
9090

9191
Example query with multiple results
9292
-----------------------------------
@@ -174,7 +174,7 @@ Further reading
174174
Answers
175175
-------
176176

177-
Answer: Exercise 1
177+
Exercise 1
178178
~~~~~~~~~~
179179

180180
.. code-block:: ql
@@ -183,7 +183,7 @@ Answer: Exercise 1
183183
where s = "lgtm"
184184
select s.length()
185185
186-
Answer: Exercise 2
186+
Exercise 2
187187
~~~~~~~~~~
188188

189189
.. code-block:: ql
@@ -192,7 +192,7 @@ Answer: Exercise 2
192192
where x = 3.pow(5) and y = 245.6
193193
select x.minimum(y).sin()
194194
195-
Answer: Exercise 3
195+
Exercise 3
196196
~~~~~~~~~~
197197

198198
.. code-block:: ql
@@ -201,7 +201,7 @@ Answer: Exercise 3
201201
where b = false
202202
select b.booleanNot()
203203
204-
Answer: Exercise 4
204+
Exercise 4
205205
~~~~~~~~~~
206206

207207
.. code-block:: ql

0 commit comments

Comments
 (0)