Loving Common Lisp, or the Savvy Programmer's Secret Weapon

Loving Common Lisp, or the Savvy Programmer's Secret Weapon

Mark Watson
Buy on Leanpub

Table of Contents

Loving Common Lisp, or the Savvy Programmer's Secret Weapon

  • Cover Material, Copyright, and License
  • Preface
    • How To Read This Book?
    • Requests from the Author
    • Why Use Common Lisp?
    • Acknowledgments
    • Setting Up Your Common Lisp Development System and Quicklisp
  • Introduction
    • Why Did I Write this Book?
    • Free Software Tools for Common Lisp Programming
    • Making Book Examples Run Portably on Most Common Lisp Implementations
    • How is Lisp Different from Languages like Java and C++?
    • Advantages of Working in a Lisp Environment
  • Common Lisp Basics
    • Getting Started with SBCL
    • Making the repl Nicer using rlwrap
    • The Basics of Lisp Programming
    • Symbols
    • Operations on Lists
    • Using Arrays and Vectors
    • Using Strings
    • Using Hash Tables
    • Using Eval to Evaluate Lisp Forms
    • Using a Text Editor to Edit Lisp Source Files
    • Recovering from Errors
    • Garbage Collection
    • Loading your Working Environment Quickly
    • Functional Programming Concepts
  • Quicklisp
    • Using Quicklisp to Find Packages
    • Using Quicklisp to Configure Emacs and Slime
  • Defining Lisp Functions
    • Using Lambda Forms
    • Using Recursion
    • Closures
    • Using the Function eval
  • Defining Common Lisp Macros
    • Example Macro
    • Using the Splicing Operator
    • Using macroexpand-1
  • Using Common Lisp Loop Macros
    • dolist
    • dotimes
    • do
    • Using the loop Special Form to Iterate Over Vectors or Arrays
  • Common Lisp Package System
  • Input and Output
    • The Lisp read and read-line Functions
    • Lisp Printing Functions
  • Plotting Data
    • Implementing the Library
    • Packaging as a Quicklisp Project
  • Common Lisp Object System - CLOS
    • Example of Using a CLOS Class
    • Implementation of the HTMLstream Class
    • Using Defstruct or CLOS
  • Network Programming
    • An introduction to Drakma
    • An introduction to Hunchentoot
    • Complete REST Client Server Example Using JSON for Data Serialization
    • Network Programming Wrap Up
  • Using the Brave Search APIs
    • Setting an Environment Variable for the Access Key for Brave Search APIs
    • Example Search Script
  • Accessing Relational Databases
    • Database Wrap Up
  • Using MongoDB, Solr NoSQL Data Stores
    • MongoDB
    • A Common Lisp Solr Client
    • NoSQL Wrapup
  • Natural Language Processing
    • Loading and Running the NLP Library
    • Part of Speech Tagging
    • Categorizing Text
    • Detecting People’s Names and Place Names
    • Summarizing Text
    • Text Mining
  • Information Gathering
    • DBPedia Lookup Service
    • Web Spiders
    • Using Apache Nutch
    • Wrap Up
  • Using The CL Machine-Learning Library
    • Using the CLML Data Loading and Access APIs
    • K-Means Clustering of Cancer Data Set
    • SVM Classification of Cancer Data Set
    • CLML Wrap Up
  • Backpropagation Neural Networks
  • Hopfield Neural Networks
  • Anomaly Detection
    • What Is a Gaussian Distribution?
    • How the Detector Works
    • The Wisconsin Breast Cancer Dataset
    • Project Structure
    • Walking Through the Code
    • Running the Example
    • Using the API in Your Own Code
    • Understanding the Evaluation Metrics
    • Wrap Up
  • Semantic Web and Linked Data
    • Resource Description Framework (RDF) Data Model
    • Extending RDF with RDF Schema
    • The SPARQL Query Language
    • Case Study: Using SPARQL to Find Information about Board of Directors Members of Corporations and Organizations
    • Installing the Apache Jena Fuseki RDF Server
    • Common Lisp Client Examples for the Apache Jena Fuseki RDF Server
  • Implementing a Simple RDF Datastore and Partial SPARQL Support in Common Lisp
    • 1. RDF Triple Structure
    • 2. RDF Datastore
    • 3. Basic Datastore Operations
    • 4. Query Support
    • 5. SPARQL Query Structure
    • 6. SPARQL Query Parsing
    • 7. Query Execution
    • 8. Result Projection
    • 9. Main Query Execution
    • Conclusion
  • Automatically Generating Data for Knowledge Graphs
    • Implementation Notes
    • Generating RDF Data
    • Generating Data for the Neo4j Graph Database
    • Implementing the Top Level Application APIs
    • Implementing The Web Interface
    • Creating a Standalone Application Using SBCL
    • Augmenting RDF Triples in a Knowledge Graph Using DBPedia
    • KGCreator Wrap Up
  • Knowledge Graph Sampler for Creating Small Custom Knowledge Graphs
    • Project Definition
    • Overview of Architecture
    • Code
  • Knowledge Graph Navigator Common Library Implementation
    • Example Output
    • Project Configuration and Running the Application
    • Review of NLP Utilities Used in Application
    • Developing Low-Level SPARQL Utilities
    • Implementing the Caching Layer
    • Utilities in the Main Library File kgn-common.lisp
    • Wrap-up
  • Knowledge Graph Navigator Text-Based User Interface
    • Example Output
    • Text User Interface Implementation
    • Wrap-up
  • Knowledge Graph Navigator User Interface Using LispWorks CAPI
    • Project Configuration and Running the Application
    • Utilities to Colorize SPARQL and Generated Output
    • Main Implementation File kgn-capi-ui.lisp
    • User Interface Utilites File user-interface.lisp
    • User Interface CAPI Options Panes Definition File option-pane.lisp
    • Using LispWorks CAPI UI Toolkit
    • Wrap-up
  • Building a MicroGPT in Common Lisp
    • Introduction
    • Demystifying the Core Components
    • Conclusion
    • Complete Source Code Listing for microgpt.lisp
    • Wrap Up
  • Using the OpenAI and Mistral APIs
    • History of OpenAI
    • Common Lisp Library for Using OpenAI APIs
    • History of Mistral AI
    • Client Library for Mistral APIs
  • Using Local LLMs With Ollama
    • Design Notes (Optional Material)
    • Implementation of Common Helper Code
    • Implementation of Generative AI Functionality
    • Implementation of Tool Use/Function Calling Generative AI Functionality
    • Using Built In Web Search Tool on Ollama Cloud
    • Ollama Chapter Wrap Up
  • Image Processing With Local Ollama Models
    • Design Notes for the Example code
    • Code to Process Images
    • Example Program Output
  • Using the Perplexity Sonar Web Search and LLM APIs
    • Example Library Use
    • Library Implementation
    • Wrap Up for the Perplexity Sonar API
    • Wrap Up Part 2: Perplexity Offers a Derivative DeepSeek R1 Model on its APIs
  • Moonshot’s Kimi K2 Model
    • Simple Text Generation
    • A More Complicated Example With Tool Use
    • Moonshot AI’s Kimi K2 Model Wrap Up
  • Using the Hugging Face Deep Learning Natural Language Processing APIs
    • History of Hugging Face and How They Differ from OpenAI and Anthropic
    • Common Lisp Library for Hugging Face APIs
    • Hugging Face APIs Wrapup
  • Knowledge Base Navigator: Building an AI-Powered Information System
    • Project Overview
    • Project Structure
    • Core Implementation
    • Running the Application
    • Key Takeaways
    • Dependencies
    • Environment Setup
  • Interfacing with External Programs: A Lightpanda Browser Client
    • The Problem: JavaScript-Rendered Web Content
    • Project Structure
    • Configuration
    • Running External Programs with UIOP
    • String Processing: Extracting Links
    • The Main API Function
    • Helper Functions
    • Usage Examples
    • Compatibility Package
    • Key Code Style Takeaways
  • Web Scraping
    • Extracting HTML Headers
    • Extracting Page Content as Plain Text
    • Converting a Web Page to Markdown
    • Wrap Up
  • Using a Local Document Embeddings Vector Database With OpenAI GPT-5 APIs for Semantically Querying Your Own Data
    • Overview of Local Embeddings Vector Database to Enhance the Use of GPT3 APIs With Local Documents
    • Implementing a Local Vector Database for Document Embeddings
    • Using Local Embeddings Vector Database With OpenAI GPT APIs
    • Testing Local Embeddings Vector Database With OpenAI GPT APIs
    • Adding Chat History
    • Wrap Up for Using Local Embeddings Vector Database to Enhance the Use of GPT5 APIs With Local Documents
  • Prompt Engineering for Large Language Models
    • Two Types of LLMS
    • Prompt Examples
    • Prompt Engineering Wrapup
  • Client Library for the Google Gemini LLM APIs
    • Example Use
    • Using Google’s “Grounding Search”
    • Using Google’s “Grounding Search” With Citations
    • Mixing Local Tools with Google Platform Tools Using the Interactions APIs.
  • Client Library for the Tavily Web Search APIs
    • Example Use
  • AutoContext: Prepare Effective Prompts with Context for LLM Queries
    • Implementing the BM25 Algorithm
    • Implementing Vectorization of Text and Semantic Similarity
    • Implementation of Main Program
    • Example Generated Prompt with Context
    • Wrap Up For Generating Prompts with Contexts
  • Agents Orchestrating LLM Tool Use
    • Example Multi Agent Implementation
    • Code Discusion
    • test.lisp
    • Example Output
    • Multi Agent Example Wrap Up
  • More Agents Using X’s Grok and Perplexity APIs
    • Agent Using X’s Grok API
    • Agent Using X’s Grok API and Perplexity’s Search API
  • New LLM Library With Tool Support
    • Library Structure Overview
    • Source Code
    • Defining Tools — example_tools.lisp
    • Testing the Claude Backend — claude_test.lisp
    • Example Program Output
    • Wrap Up
  • Using Common Lisp with Wolfram/One
  • Symbolic Mathematics in Common Lisp
    • The Data Layer
    • Symbolic Differentiation
    • Symbolic Integration
    • Wrap Up
  • WebKit Applications - macOS Only
    • Architecture Overview
    • Prerequisites and Building
    • Project Structure
    • The C Shim
    • CFFI Bindings
    • The Bridge: JS <—> Lisp Communication
    • High-Level API
    • Example 1: Hello World
    • Example 2: Counter App with Bridge
    • Example 3: Markdown File Viewer
    • API Reference Summary
    • Key Takeaways
  • A Daily-Use Gemini REPL with Search Grounding and Persistent Cache
    • How It Works
    • Prerequisites
    • Project Structure
    • The Main Application
    • Running the Tool
    • Example Session
    • REPL Command Reference
    • Key Takeaways
  • Building an AI Coding Assistant for Common Lisp
    • Architecture
    • Project Structure
    • File-System Tools
    • The Agent Core
    • Installation
    • Usage Examples
    • Example Session
    • Comparison with cl-llm-agent
    • Key Takeaways
    • Wrap Up for cl-llm-agent
  • Hacking the SBCL REPL
    • Shell Access via a Reader Macro
    • AI Coding Agent Integration
  • Book Wrapup
Loving Common Lisp, or the Savvy Programmer's Secret Weapon/