Vadalog notebooks

Notebooks are great storytelling devices, allowing you to interleave Markdown elements like images, math equations, and explanatory text with your code and its execution results. Notebooks can be a perfect way to share and explain your ideas.

They make also great REPLs (read-eval-print loop), interactive applications where you can write a few lines of code and execute the code immediately and see the output, keeping the results along the way.

Vadacode supports Vadalog notebooks, which allow for the interactive use of Vadalog.

Vadalog notebook experience may be different from what you may expect from a language like Python. In particular, in Vadalog Notebooks the execution of each cell is independent from the others (no volatile results are persisted between executions). For example, if you assign an atom in a cell, it does not become available in other cells. Nevertheless, you can do sequential processing by explictly persisting data using @input, @output and @bind statements.

Create or open a Vadalog Notebook

You can create a Vadalog Notebook by running the Vadalog: Create notebook command from the Command Palette (+Shift+P on macOS or Ctrl+Shift+P on Windows/Linux) or by creating a new .vadanb file in your workspace.

notebook create
Figure 1. Vadacode-created stub Vadalog notebook

If you have an existing Vadalog Notebook, you can open it by right-clicking on the file and opening with VS Code, or through the VS Code File Explorer.

Running cells

Vadacode notebooks send requests to the endpoint specified in the Vadalog endpoint setting.

Run a single code cell

Once your code is added, you can run a cell using the Run icon to the left of the cell and the output will be displayed below the code cell.

notebook run
Figure 2. Execution of a notebook cell

To run a selected code cell, you can also use keyboard shortcuts in both command and edit mode. Ctrl+Enter runs the currently selected cell. Shift+Enter runs the currently selected cell and inserts a new cell immediately below (focus moves to new cell). Alt+Enter runs the currently selected cell and inserts a new cell immediately below (focus remains on current cell).

Run multiple code cells

Running multiple code cells can be accomplished in many ways. You can use the double arrow in the main toolbar of the Notebook Editor to run all cells within the Notebook or by selecting Run All Above or Run All Below buttons of the current code cell.

notebook run all
Figure 3. Execution of all notebook cells

Save your Vadalog Notebook

You can save your Vadalog Notebook using the keyboard shortcut Ctrl+S or File  Save.

IntelliSense support in the Vadalog Notebook Editor

The Vadalog Notebook Editor window has full IntelliSense – code completions, member lists, quick info for methods, and parameter hints. You can be just as productive typing in the Notebook Editor window as you are in the code editor.

notebook intellisense
Figure 4. Notebook integration with Visual Studio Code Intellisense

Further information

Further information about Visual Studio Code notebooks and a full usage guide can be found at Jupyter Notebooks in VS Code.