brain

tamnd's digital brain — notes, problems, research

42740 notes

Custom Formatting

Zig has a formatting system built into the standard library. You have already used it many times through std.debug.print.

zigbook
What Actually Makes Programs Slow?

Performance is one of the main reasons people choose Zig.

zigbook
Memory Mapped Files

A memory mapped file is a file that the operating system places into your program's address space.

zigbook
Threads in Zig

A thread is a separate path of execution inside one program.

zigbook
Why Zig Works Well with C

Zig works unusually well with C because it treats C as a first-class part of systems programming.

zigbook
Zig Test Framework

Zig has a built-in test system. You do not need a separate testing library to start writing tests.

zigbook
Introduction to `build.zig`

Zig has a built-in build system.

zigbook
Tour of `std`

std is Zig’s standard library.

zigbook
Importing ArrayList

An ArrayList is one of the most important data structures in Zig.

zigbook
Why Zig Uses Allocators

Memory is one of the most important ideas in Zig.

zigbook
Understanding `@` Builtins

Zig has special built-in functions whose names start with @.

zigbook
What Is `comptime`

comptime means “compile time.”

zigbook
Optional Types

An optional type is a type that can hold either a value or no value.

zigbook
Struct Methods

A struct method is a function that belongs to a struct.

zigbook
Multidimensional Arrays

A multidimensional array is an array whose elements are also arrays.

zigbook
Many Item Pointers

A many item pointer is a pointer that can move across several values of the same type.

zigbook
`try`

try is the most common way to handle errors in Zig.

zigbook
A First Example

Recursion is a technique where a function calls itself.

zigbook
Struct Definitions

A struct is a type that groups several values together.

zigbook
Array Literals

An array literal is the syntax you use to write array values directly in source code.

zigbook
Single Item Pointers

A pointer is a value that stores the address of another value.

zigbook
Error Union Types

An error union type means:

zigbook
Returning a Struct

Many functions need to produce more than one piece of information.

zigbook
`break` and `continue`

Loops repeat code. But sometimes you do not want a loop to finish in the normal way.

zigbook
Fixed Arrays

An array is a group of values stored next to each other.

zigbook
Memory Model Basics

Memory is where a program keeps its data while it runs.

zigbook
Error Sets

An error set is a group of possible error names.

zigbook
Labels and Block Expressions

Zig has blocks.

zigbook
The `return` Keyword

Functions often need to produce results.

zigbook
Reserved Keywords

A keyword is a word that has special meaning in Zig.

zigbook
Why Zig Has No Exceptions

Most programming languages need a way to handle failure.

zigbook
`for` Loops

A while loop repeats while a condition is true.

zigbook
`while` Loops

Programs often need to repeat work.

zigbook
Naming Conventions

Names are part of the program.

zigbook
Parameter Syntax

Function parameters are the inputs of a function.

zigbook
The Structure of a Function

Functions are reusable blocks of code.

zigbook
`switch`

An if statement is good for general conditions:

zigbook
Comments and Documentation

Comments are notes for humans who read the code.

zigbook
Strings and UTF-8

A string is text.

zigbook
Zero Values and Initialization

Initialization means giving a value to something when it is created.

zigbook
Undefined Values

In Zig, undefined means “this value has not been initialized.”

zigbook
Type Inference

Type inference means Zig can figure out a type from the value you write.

zigbook
Booleans and Comparisons

A boolean is a value that can be only one of two things:

zigbook
Floating Point Numbers

Floating point numbers are numbers with fractional parts.

zigbook
Integer Types and Overflow

Integers are whole numbers.

zigbook
Primitive Types

Every value in a Zig program has a type.

zigbook
Reading Zig Error Messages

Sooner or later, every Zig beginner meets the compiler.

zigbook
Editors, LSP, and Debuggers

You can write Zig code in any text editor.

zigbook
Project Structure

So far, we have used single-file programs.

zigbook
Zig Compiler as a Toolchain

When beginners hear the word “compiler,” they often think of one job:

zigbook
Understanding `zig build-exe`

In the previous section, we used this command:

zigbook
Your First Zig Program

Now we will write and run a complete Zig program.

zigbook
Zig Release Channels and Versioning

Before writing larger Zig programs, you need to understand an important fact:

zigbook
Installing Zig

Before we write more Zig code, we need the Zig compiler.

zigbook
Why Zig Exists

Zig exists because low-level programming is still important, but the old tools have painful tradeoffs.

zigbook
`if` Expressions

Programs need to make choices.

zigbook
Variables and Constants

A program stores values so it can use them later. In Zig, you store values with two main keywords:

zigbook
What Is Zig

Zig is a programming language for writing programs that are fast, clear, and close to the machine.

zigbook
What Is Zig

Zig is a programming language for writing fast, small, reliable programs.

zigbook
What Is Zig

Zig is a programming language for writing fast, small, reliable programs.

zigbook
Appendix A.1 Sets and Functions

A set is a collection of objects called elements.

number-theorybook
Future Directions in Number Theory

Modern number theory continues to evolve rapidly.

number-theorybook
The Langlands Program

The Langlands program is one of the largest and most influential research programs in modern mathematics.

number-theorybook
The Birch and Swinnerton-Dyer Conjecture

An elliptic curve over $\mathbb{Q}$ may be written in Weierstrass form

number-theorybook
The Riemann Hypothesis

The Riemann zeta function is one of the central objects in mathematics.

number-theorybook
Fermat's Last Theorem

Fermat's Last Theorem states that there are no positive integers

number-theorybook
Open Problems in Number Theory

Number theory contains some of the oldest and deepest unsolved problems in mathematics.

number-theorybook
Arithmetic Statistics

Arithmetic statistics studies the distribution of arithmetic objects inside large families.

number-theorybook
Probabilistic Models for Primes

Prime numbers are deterministic objects, but many aspects of their distribution resemble random behavior.

number-theorybook
Random Matrices and Zeta Zeros

The Riemann zeta function is defined for $\operatorname{Re}s>1$ by

number-theorybook
Parity Problem

Sieve methods are extremely effective for estimating how many integers avoid small prime factors. They have produced major results about:

number-theorybook
Chen's Theorem

The Twin Prime Conjecture states that infinitely many primes satisfy

number-theorybook
Probabilistic Algorithms

A probabilistic algorithm uses random choices during its execution. In number theory, this is often a practical advantage rather than a weakness.

number-theorybook
Bombieri-Vinogradov Theorem

The Prime Number Theorem for arithmetic progressions states that for

number-theorybook
Geometric Langlands Theory

The classical Langlands program relates:

number-theorybook
Hints for Selected Problems

Write the two integers as

number-theorybook
Brun-Titchmarsh Theorem

One of the central problems of analytic number theory is understanding how primes distribute among residue classes.

number-theorybook
Probabilistic Primality

A primality test determines whether an integer is prime.

number-theorybook
Shimura Varieties

Modular curves parameterize elliptic curves and connect modular forms with arithmetic geometry.

number-theorybook
Trace Formulas

Fourier analysis decomposes functions into harmonic frequencies.

number-theorybook
Large Sieve

Classical sieve methods estimate how many integers survive congruence restrictions. The large sieve approaches these problems from a different direction.

number-theorybook
Frobenius Automorphisms

One of the deepest ideas in algebraic number theory is that prime numbers possess hidden symmetry inside field extensions.

number-theorybook
Decomposition and Inertia Groups

Let

number-theorybook
Selberg Sieve

Brun's sieve introduced the idea of estimating sifted sets through truncated inclusion-exclusion. However, Brun's method often produced bounds that were technically difficult...

number-theorybook
Smooth Numbers

A positive integer is called $y$-smooth if all of its prime factors are at most $y$.

number-theorybook
Automorphic $L$-Functions

The Riemann zeta function

number-theorybook
Brun Sieve

Sieve methods are techniques for counting integers that remain after removing residue classes modulo primes.

number-theorybook
Ramification of Primes

In the ordinary integers, every nonzero integer factors uniquely into prime numbers.

number-theorybook
Random Integers

Number theory often studies exact statements about individual integers. For example, one may ask whether a given integer is prime, squarefree, smooth, or representable as a...

number-theorybook
Functoriality

The Langlands program predicts that many different arithmetic objects are connected by systematic transfers.

number-theorybook
Schnirelmann Density

In additive number theory, ordinary asymptotic density is often too weak to control additive behavior.

number-theorybook
Local Fields

Classical number theory studies arithmetic globally over fields such as

number-theorybook
Zero-Knowledge Proofs

A zero-knowledge proof allows one party to convince another that a statement is true without revealing why it is true.

number-theorybook
Galois Representations

Galois groups encode the symmetries of algebraic equations and field extensions.

number-theorybook
Additive Bases

A central question in additive number theory asks whether every integer can be represented as a sum of elements from a fixed set.

number-theorybook
$p$-Adic Numbers

The real numbers arise by completing the rational numbers using the ordinary absolute value. The $p$-adic numbers arise by completing the rational numbers using the $p$-adic...

number-theorybook
Post-Quantum Cryptography

Modern public-key cryptography relies heavily on two computational assumptions:

number-theorybook
The Langlands Program

The Langlands program is one of the most ambitious and influential theories in modern mathematics.

number-theorybook
Exponential Sums

Exponential sums are among the central tools of analytic number theory.

number-theorybook
Valuations and Absolute Values

In ordinary analysis, the absolute value

number-theorybook