Skip to content

Commit 721c721

Browse files
committed
ADDED: Tutorial explaining how the notebook types interact
1 parent 919e071 commit 721c721

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

examples/notebook.swinb

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<div class="notebook">
2+
3+
<div class="nb-cell markdown" name="md1">
4+
# Selecting and ordering program cells
5+
6+
SWISH notebooks may contain several cell types. For this tutorial we consider two: _program_ cells and _query_ cells. A program cell contains a valid Prolog program, while a query cell contains a query, typically calling code defined in the Prolog cell. SWISH defines three types of program cells:
7+
8+
- __global__ &lt;br&gt;
9+
Such cells are identified by a globe. They are used by all
10+
query cells on the notebook.
11+
- __below__ &lt;br&gt;
12+
These are identified by a down arrow. Only "below" cells
13+
that appear above the query are added.
14+
- __local__ &lt;br&gt;
15+
Finally, the __last local cell above the query is added__
16+
if there is no other program cell in between.
17+
18+
The cells are loaded in the order in which they appear on the page.
19+
20+
The intend is that __global__ cells are used to provide background data and they are normally placed at the end of the notebook. __Below__ cells are used to build up a program _incrementally_ and __local__ cells provides predicates to be called by the immediately following queries or predicates that _parameterize_ global or below cells.
21+
22+
When a query is selected, a thin blue line is added to the left of all cells that are loaded before the query is executed. You can experiment using the content below, changing the status of program cells (by clicking the icon) and selecting the query to see which cells are used for the query. Running the query presents a table with answers.
23+
</div>
24+
25+
<div class="nb-cell program" data-background="true" name="p1">
26+
p(1).
27+
</div>
28+
29+
<div class="nb-cell program" name="p2">
30+
p(2).
31+
</div>
32+
33+
<div class="nb-cell program" data-background="true" data-below="true" name="p3">
34+
p(3).
35+
</div>
36+
37+
<div class="nb-cell program" name="p4">
38+
p(4).
39+
</div>
40+
41+
<div class="nb-cell query" data-chunk="10" data-tabled="true" name="q1">
42+
p(X)
43+
</div>
44+
45+
<div class="nb-cell program" data-background="true" data-below="true" name="p5">
46+
p(5).
47+
</div>
48+
49+
<div class="nb-cell program" data-background="true" name="p6">
50+
p(6).
51+
</div>
52+
53+
</div>

examples/swish_tutorials.swinb

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ This notebook provides an overview of tutorials about using SWISH.
1111
- [Using __R__ in SWISH](example/Rserve.swinb) (statistics, charts, machine learning)
1212
- [Accessing external *data*](example/data_source.swinb) (CSV, SPARQL, etc.)
1313
- Advanced topics for *notebooks*
14+
- [How is the program assembled for a specific query?](example/notebook.swinb)
1415
- [Parameterized queries in notebooks](example/query_parms.swinb)
1516
- Using HTML cells in notebooks
1617
- [The basics](example/htmlcell.swinb)

0 commit comments

Comments
 (0)