summaryrefslogtreecommitdiff
path: root/misc/test.tex
blob: 7085f907d5f311d71f614e287010fc82a48baa27 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55

\documentclass[debug]{microstructure}

\author{DistressNetwork°}
\lstset{escapechar=§}

\begin{document}

\resetv{-3\unit}\section{Hello world in Zig}

This is an example `hello world' program.

\vspace{-0.5\unit}{\footnotesize\italic{*:}}\vspace{-1\unit}
\begin{codeblock}
§\textrm{\italic{(Imports)}}§

pub fn main() !void {
	§\textrm{\italic{(Print)}}§
}
\end{codeblock}

We first import the standard library.

\vspace{-0.5\unit}{\footnotesize\italic{Imports:}}\vspace{-1\unit}
\begin{codeblock}
const std = @import("std");
\end{codeblock}

Then we print the desired string.

\vspace{-0.5\unit}{\footnotesize\italic{Print:}}\vspace{-1\unit}
\begin{codeblock}
std.debug.print("Hello world\n", .{});
\end{codeblock}

We can also print using a format string.

\vspace{-0.5\unit}{\footnotesize\italic{+ Print:}}\vspace{-1\unit}
\begin{codeblock}
std.debug.print("Hello world {s}\n", .{"again"});
\end{codeblock}

Or we can use a \mono{writer()} method and write to stdout directly.

\vspace{-0.5\unit}{\footnotesize\italic{+ Imports:}}\vspace{-1\unit}
\begin{codeblock}
const write = std.io.getStdOut().writer().write;
\end{codeblock}

\vspace{-0.5\unit}{\footnotesize\italic{+ Print:}}\vspace{-1\unit}
\begin{codeblock}
_ = try write("Hello stdout\n");
\end{codeblock}

\end{document}