Preface
- The Example Programs
- How to Read This Book
- Setup
- License for the Book Manuscript: Creative Commons
- Hire the Author as a Consultant
- A Short Note on My AI Journey
- Acknowledgements
A Quick OCaml Tutorial
- Installing OCaml and the Tools
- A First Program
- The REPL
- Pattern Matching and Recursion
- if / then / else Is an Expression
- Branching and Option Values
- match Expressions
- let Bindings for Local Values
- Composing and Applying Functions
- The Map Functor
- Variant Types and a Custom Order
- Tutorial Wrap Up
Functional Patterns: State, Laziness, Timing, and Debugging
- A State Module
- The Same State with Effect Handlers
- Lazy Sequences and Trace Debugging
- Timing and Timeouts
Input/Output and Command-Line Applications
- Reading a Whole File
- Mapping Over the Result of a Read
- Words Two Files Share
- Reading From the Console
- An Interactive Loop
- A Guessing Game With State
- Handling a Missing File
- Running the Examples
Testing OCaml Code with Alcotest
- Project Layout: Library, Program, and Tests
- The Interface File
- The Implementation
- Writing Tests
- Running the Suite
Symbolic Mathematics
- Exact Rationals
- Modeling the Math
- Polynomials and Normalization
- Evaluating a Polynomial
- Differentiation
- Integration and Definite Integrals
- Running It
Text Processing and DataFrames
- Cleaning Free Text
- Reading CSV
- Round-Tripping JSON
- A Small DataFrame
- The Housing Analysis
- Running It
Natural Language Processing
- A Part-of-Speech Tagger
- An NLP Toolkit
SQLite Databases
- Typed Queries
- Running a Query
- Lwt and Threading Results
- Opening the Connection
- Building and Running
RDF Data Stores and SPARQL Queries
- Modeling Triples and Queries
- Matching a Pattern
- The Join
- Running Queries as Data
- Parsing SPARQL Text
- Querying DBpedia Over HTTP
- Running Both
Web Scraping
- Parsing HTML
- Fetching a Page
- Putting It Together
- Running It
Networking and Web Applications
- A TCP Server and Client
- Web Applications with Dream
- A Web View With a JavaScript Bridge
- A Chat App Backed by Gemini
Using Large Language Model APIs
- A Local Ollama Client
- An OpenAI Chat Client
- A Gemini Client
- Entity Extraction With a Model
- Running the Clients
Search APIs: Brave Search
- Modeling a Result
- Decoding Optional Fields
- Formatting a Result
- The HTTP Call
- Running It
Knowledge Graph Creator
- The Pipeline
- Reading Input
- Generating RDF Triples
- Generating Neo4j Cypher
- Batch Processing
- Running It
AI for Games
- Blackjack
- Contract Bridge
- Go
Neural Networks from Scratch
- The Network
- The Forward Pass
- Measuring Error
- Backpropagation
- Training
- Learning XOR
- A Curved Boundary
- Testing a Network
- Where to Go Next