Leanpub Header

Skip to main content

Little Bits of Common Lisp

Seventeen tiny programs: LLMs, the web, macOS automation, classic AI, and symbolic math - each in a single file

Little Bits of Common Lisp
This book is 100% completeLast updated on 2026-10-31

Common Lisp is a great language for both small and large projects. Here we use small complete Common Lisp scripts to solve practical problems, and dear reader, hopefully have fun!

Minimum price

Free!

$11.00

You pay

Author earns

$

Also available for 1 book credit with a Reader Membership

PDF
EPUB
WEB
APP
About

About

About the Book

Little Bits of Common Lisp teaches you practical Common Lisp through seventeen complete, single-file programs. Most  files use fewer than one hundred lines of code. You can read any chapter in minutes and run the script right away from your terminal with SBCL, or load every function into one interactive REPL session. The book skips complex  project setups and partial code fragments. Every chapter prints the full source file, explains how the code works,  shows real output, and suggests ways to adapt the code for your own work.

You will write scripts that connect Common Lisp to modern AI models, web data, and your desktop. The programs call large language models through Google Gemini, local Ollama servers, and Apple on-device models. Other scripts query Exa and Brave search APIs, fetch facts from Wikidata and DBpedia with SPARQL, parse HTML, render JavaScript pages  with a headless browser, and automate macOS apps with AppleScript. Network scripts call curl directly to avoid third-party library problems and keep your code short.

You will also code classic AI and math algorithms from scratch in standard Common Lisp with zero external  dependencies. These files implement Bayesian inference, BM25 document ranking, Hopfield neural networks, an RDF triple store, a vector store, an extractive text summarizer, symbolic polynomial calculus, and reverse-mode automatic differentiation. Whether you already use Common Lisp or want to learn by reading working code, this book gives you a clear set of programs you can run and reuse today.

Share this book

Author

About the Author

Mark Watson

Mark Watson is a consultant specializing in LLMs, deep learning, machine learning, knowledge graphs, and general artificial intelligence software development. He uses Common Lisp, Clojure, Python, Java, Haskell, and Ruby for development.

He is the author of 20+ published books on Artificial Intelligence, Deep Learning, Java, Ruby, Machine Learning, Common LISP, Clojure, JavaScript, Semantic Web, NLP, C++, Linux, and Scheme. He has 55 US Patents.

Mark's consulting customer list includes: Google, Capital One, Olive AI, CompassLabs, Disney, Sitescout.com, Embed.ly, and Webmind Corporation.

Mark wrote ten traditional published books for McGraw Hill, Springer Verlag, J Wiley, and Morgan Kaufman publishers before adopting the LeanPub self-publishing platform.

The Leanpub Podcast

Podcast

Podcast Episode

Contents

Table of Contents

Little Bits of Common Lisp

Preface

Introduction

  1. What you need
  2. Which chapters run as-is

On-Device AI with Apple Foundation Models

  1. The Code
  2. How It Works
  3. Running It
  4. Using It

Calling Google Gemini

  1. The Code
  2. How It Works
  3. Running It
  4. Using It

Local LLMs with Ollama

  1. The Code
  2. How It Works
  3. Running It
  4. Using It

Web Search with Exa and Brave

  1. The Code
  2. How It Works
  3. Running It
  4. Using It

Querying Knowledge Graphs with SPARQL

  1. The Code
  2. How It Works
  3. Running It
  4. Using It

JavaScript-Rendered Pages with Lightpanda

  1. The Code
  2. How It Works
  3. Running It
  4. Using It

Web Scraping with Plump

  1. The Code
  2. How It Works
  3. Running It
  4. Using It

Automating macOS with AppleScript

  1. The Code
  2. How It Works
  3. Running It
  4. Using It

Bayesian Inference

  1. The Code
  2. How It Works
  3. Running It
  4. Using It

Ranking Documents with BM25

  1. The Code
  2. How It Works
  3. Running It
  4. Using It

Associative Memory with Hopfield Networks

  1. The Code
  2. How It Works
  3. Running It
  4. Using It

A Tiny Triple Store

  1. The Code
  2. How It Works
  3. Running It
  4. Using It

A Tiny Vector Store

  1. The Code
  2. How It Works
  3. Running It
  4. Using It

Extractive Text Summarization

  1. The Code
  2. How It Works
  3. Running It
  4. Using It

Symbolic Polynomial Math

  1. The Code
  2. How It Works
  3. Running It
  4. Using It

Scalar Automatic Differentiation

  1. The Code
  2. How It Works
  3. Running It
  4. Using It

Loading Everything Interactively to Experiment with all Book Examples at Once

  1. The Code
  2. How It Works
  3. Running It
  4. Using It

Also by the Author

Also by the Author

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub