You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/codeql/writing-codeql-queries/introduction-to-ql.rst
+16-16Lines changed: 16 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,39 +54,39 @@ Simple exercises
54
54
55
55
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.
56
56
57
-
Exercise 1
58
-
~~~~~~~~~~
57
+
Exercise 1 - Strings
58
+
~~~~~~~~~~~~~~~~~~~~
59
59
60
60
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.)
61
61
62
-
➤ `Check your answer <#answer:-exercise-1>`__
62
+
➤ `Check your answer <#exercise-1>`__
63
63
64
64
There is often more than one way to define a query. For example, we can also write the above query in the shorter form:
65
65
66
66
.. code-block:: ql
67
67
68
68
select "lgtm".length()
69
69
70
-
Exercise 2
71
-
~~~~~~~~~~
70
+
Exercise 2 - Numbers
71
+
~~~~~~~~~~~~~~~~~~~~
72
72
73
73
Write a query which returns the sine of the minimum of ``3^5`` (``3`` raised to the power ``5``) and ``245.6``.
74
74
75
-
➤ `Check your answer <#answer:-exercise-2>`__
75
+
➤ `Check your answer <#exercise-2>`__
76
76
77
-
Exercise 3
78
-
~~~~~~~~~~
77
+
Exercise 3 - Booleans
78
+
~~~~~~~~~~~~~~~~~~~~~
79
79
80
80
Write a query which returns the opposite of the boolean ``false``.
81
81
82
-
➤ `Check your answer <#answer:-exercise-3>`__
82
+
➤ `Check your answer <#exercise-3>`__
83
83
84
-
Exercise 4
85
-
~~~~~~~~~~
84
+
Exercise 4 - Dates
85
+
~~~~~~~~~~~~~~~~~~
86
86
87
87
Write a query which computes the number of days between June 10 and September 28, 2017.
0 commit comments