Gerbil Scheme in Action

Gerbil Scheme in Action

Mark Watson
Buy on Leanpub

Table of Contents

Gerbil Scheme in Action

  • Preface
    • New Material Added in Latest Edition
    • A Comment on Licenses
    • Running Gerbil Scheme on macOS and Linux
    • History and Background to the Gerbil Scheme Project
    • Core Gerbil Toolkits Used in this Book: :std/net/request and :std/text/json
    • Suppressing or Fixing Compilation Warning Messages on macOS
  • Setting Up Gerbil Scheme Development Environment
    • Emacs Configuration
  • Google Gemini API
    • Example Code
    • Example Output
    • Optional Practice Problems
  • Ollama
    • Example Code
    • Install Ollama and Pull a Model to Experiment With
    • Example Output
    • Tool/Function Calling with Ollama
    • Defining Tools: example_tools.ss
    • The Agent Loop: use_tools.ss
    • Tool Calling Example Output
    • Building Your Own Tools
    • Optional Practice Problems
  • OpenAI API
    • Example Code
    • Example Output
    • Optional Practice Problems
  • Inexpensive and Fast LLM Inference Using the Groq Service
    • Structure of Project and Build Instructions
    • groq_inference.ss Utility
    • Example scripts: kimi2.ss and gpt-oss-120b.ss
    • Optional Practice Problems
  • Code for Natural Language Processing (NLP)
    • Structure of Project and Build Instructions
    • Top Level Project Code
    • Other Source Files
    • Test Run:
    • Building and Running the Command Line Tool
    • Optional Practice Problems
  • Gerbil Scheme FFI Example Using the C Language Raptor RDF Library
    • Implementation of a FFI Bridge Library for Raptor
    • Test Code
    • Build System
    • Optional Practice Problems
  • Complete FFI Example: C Language Wrapper for Rasqal SPARQL Library and Sord RDF Datastore Library
    • Library Selection
    • Overview of the Project Structure and Build System
    • Implementation of the C Language Wrapper
    • A Gerbil Scheme Shim to Call The C Language Wrapper Code
    • Gerbil Scheme Main Program for this Example
    • Example Output
    • Optional Practice Problems
  • WebKit Applications - macOS Only
    • Architecture Overview
    • Prerequisites and Building
    • Project Structure
    • The C Shim
    • Gambit FFI Bindings
    • The Bridge: JS to Scheme Communication
    • High-Level API
    • Example 1: Hello World
    • Example 2: Counter App with Bridge
    • Example 3: Markdown File Viewer
    • The Build System
    • Comparing Common Lisp and Gerbil Versions
    • API Reference Summary
    • Key Takeaways
    • Optional Practice Problems
  • A Simple In-Memory RDF Store and Query Language in Gerbil Scheme
    • Introduction to RDF and the Goal of This Chapter
    • Data Model: Triples and the Store
    • Parsing SPARQL Queries
    • Query Evaluation: Pattern Matching and Joining
    • Gerbil RDF Implementation
    • Running the Demo and Using the Code
    • Summary and Further Directions
    • Optional Practice Problems
  • Introduction To Writing Command Line Utilities
    • Overview of the Command Line Utilities Project Structure and Build System
    • Simple Structure for Command Line Utilities
    • A More Flexible Structure for Command Line Utilities
    • Wrap Up for Writing Command Line Utilities in Gerbil Scheme and Notes On User Built Libraries
    • Optional Practice Problems
  • Command Line Applications For NLP
    • Re-using the NLP Library For a Command Line Utility to Identify Categories or Topics in Input Text
    • Using OpenAI’s GPT-5 model To Summarize Input Text
    • Optional Practice Problems
  • Gaussian Anomaly Detection
    • Theoretical Background
    • The Dataset
    • Project Structure
    • The Detector Module: detector.ss
    • The Demo Program: wisconsin_demo.ss
    • Running the Demo
    • Interpreting the Results
    • Wrap Up
    • Optional Practice Problems
  • K-means Clustering
    • Theoretical Background
    • The Dataset
    • Project Structure
    • The K-means Library: kmeans-lib.ss
    • The Demo Program: test.ss
    • Running the Demo
    • Interpreting the Results
    • Wrap Up
    • Optional Practice Problems
  • Building a Chess Engine and AI Bot
    • Theoretical Background
    • Project Structure
    • The Engine Module: engine.ss
    • The AI Module: ai.ss
    • The CLI Module: cli.ss
    • The Perft Module: perft.ss
    • Running the Code
    • Interpreting the Output
    • Wrap Up
    • Practice Problems
  • Building a Personal AI Assistant CLI with Gerbil Scheme
    • The Idea: Your Own AI Terminal Companion
    • Theory: Grounding, RAG, and the Context Window
    • Project Structure
    • The Cache Module
    • The Main REPL Module
    • Building and Running
    • Sample Session
    • Interpreting the Results
    • Wrap Up
    • Practice Problems
  • Reinforcement Learning: Value Iteration and Q-Learning
    • Theoretical Background
    • Project Structure
    • Example 1: Value Iteration on a 3×3 Grid World
    • Example 2: Q-Learning on FrozenLake
    • Wrap Up
    • Optional Practice Problems
  • Web Scraping in Gerbil Scheme
    • What We Will Build
    • Why Regular Expressions and Not a Real Parser
    • Project Structure
    • The Library: webscrape.ss
    • The Test Program: test_webscrape.ss
    • Running the Test Driver
    • Interpreting the Output
    • Design Choices and Limitations
    • Wrap Up
    • Optional Practice Problems
Gerbil Scheme in Action/