Skip to content

Commit 94d55e9

Browse files
author
Shati Patel
committed
QL HB: Use "real" example
1 parent b68f9f7 commit 94d55e9

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

docs/language/ql-handbook/predicates.rst

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -274,16 +274,19 @@ That is, ``bindingset[x] bindingset[y]``, which states that at least one of ``x`
274274
be bound, is different from ``bindingset[x, y]``, which states that both ``x`` and ``y`` must be
275275
bound.
276276

277-
The latter can be useful when you want to declare a :ref:`predicate with result <predicates-with-result>` that takes multiple input arguments::
278-
279-
bindingset[a, b]
280-
int getSum(int a, int b) {
281-
result = a + b
277+
The latter can be useful when you want to declare a :ref:`predicate with result <predicates-with-result>` that takes multiple input arguments.
278+
For example, the following predicate gets ``str``, truncated to a maximum length of ``len`` characters::
279+
280+
bindingset[str, len]
281+
string truncate(string str, int len) {
282+
if str.length() > len
283+
then result = str.prefix(len)
284+
else result = str
282285
}
283286

284287
You can then use this in a :ref:`select clause <select-clauses>`, for example::
285288

286-
select getSum(3, 5)
289+
select truncate("hello world", 5)
287290

288291
.. _database-predicates:
289292

0 commit comments

Comments
 (0)