Skip to content

Latest commit

 

History

History
255 lines (215 loc) · 7.38 KB

File metadata and controls

255 lines (215 loc) · 7.38 KB

Clojure Brain Teasers Review

Review and solutions for ‘Clojure Brain Teasers’ by Alex Miller and Lorilyn Jordan Miller - a collection of 25 puzzles that explore Clojure’s quirks and common pitfalls around equality, collections, evaluation, and runtime behavior.

book-cover.png

Overview

This repository contains notes and examples from working through the puzzles in “Clojure Brain Teasers”. The book explores common misconceptions and edge cases in Clojure around:

  • Basics
  • Collections
  • Evaluation
  • Runtime and Library

Structure

.
├── LICENSE
├── README.org
├── spec.org                  # Project goals and specification
├── deps.edn                  # Dependency configuration
├── Makefile                   # Build automation (gmake)
├── shell.nix                  # Nix development environment
├── .clj-kondo/                # Linter configuration
├── .github/workflows/         # CI/CD pipelines
├── scripts/                   # Utility scripts
├── doc/
│   ├── learning-clojure-puzzles.org
│   ├── KNOWLEDGE_MAP.org
│   ├── RELEASES.md
│   ├── TEST_PROGRESS.md
│   └── development/           # Style guide and resources
├── src/
│   ├── basics/                # Puzzles 1-5
│   ├── collections/           # Puzzles 6-11
│   ├── evaluation/            # Puzzles 12-17
│   ├── runtime/               # Puzzles 18-25
│   └── clojurescript/         # ClojureScript-specific teasers
└── test/                      # Mirrors src/ structure
    ├── basics/
    ├── collections/
    ├── evaluation/
    ├── runtime/
    └── clojurescript/

Development Workflow

flowchart TB
    subgraph make["Make Targets"]
        direction TB
        init["init\n(create dirs)"]
        deps["deps\n(install deps)"]
        clean["clean\n(cleanup)"]
        check["check\n(lint + test)"]
        fmt["fmt\n(format code)"]
        lint["lint\n(clj-kondo)"]
        test["test\n(run tests)"]
        repl["repl\n(dev console)"]
        build["build\n(full build)"]
        docs["docs\n(cover + qr)"]
    end

    subgraph deps_edn["deps.edn Aliases"]
        direction TB
        test_runner[":test\ncognitect"]
        dev[":dev\ntools"]
        clj_kondo[":lint\nkondo"]
        cljfmt[":fmt\ncljfmt"]
        portal[":portal\nviz"]
        coverage[":test\ncoverage"]
        deps_graph[":graph\ndeps"]
        build_tools[":build\ntools"]
    end

    subgraph workflow["Development Workflow"]
        direction LR
        setup --> develop
        develop --> verify
        verify --> deploy
    end

    %% Stage connections
    init --> setup
    deps --> setup
    
    repl --> develop
    fmt --> develop
    portal --> develop
    
    lint --> verify
    test --> verify
    check --> verify
    coverage --> verify
    
    build --> deploy
    deps_graph --> deploy

    %% Tool connections 
    test --> test_runner
    fmt --> cljfmt
    lint --> clj_kondo
    repl --> dev
    build --> build_tools

    classDef default fill:#f9f9f9,stroke:#333,stroke-width:1px
    classDef workflow fill:#d4e6f1,stroke:#2874a6,stroke-width:2px
    classDef make fill:#e8f5e9,stroke:#2e7d32,stroke-width:1px
    classDef deps fill:#fff3e0,stroke:#ef6c00,stroke-width:1px

    class workflow workflow
    class make,init,deps,clean,check,fmt,lint,test,repl,build,docs make
    class deps_edn,test_runner,dev,clj_kondo,cljfmt,portal,coverage,deps_graph,build_tools deps
Loading

Setup

qr-code.png

  1. Install Clojure CLI tools
  2. Clone this repository
  3. Initialize the project structure:
    make init
        
  4. Install dependencies:
    make deps
        

Development Tools

Configuration

Org Babel

(org-babel-do-load-languages
 'org-babel-load-languages
 '((clojure . t)
   (shell . t)
   (emacs-lisp . t)))

(setq org-babel-clojure-backend 'cider
      org-confirm-babel-evaluate nil
      org-src-preserve-indentation t
      org-babel-default-header-args
      '((:mkdirp . "yes")
        (:tangle . "yes")
        (:comments . "org")))

Installation

Using Homebrew

brew install clojure make git imagemagick ghostscript qrencode gh

Using Nix

{ pkgs ? import <nixpkgs> {} }:

pkgs.mkShell {
  buildInputs = with pkgs; [
    clojure
    gnumake
    git
    ghostscript
    imagemagick
    qrencode
    gh
  ];
}

Development Environment

Core Tools

ToolPurposeVersion
clojureClojure CLI & deps1.11.1
makeBuild automation4.4+
gitVersion control2.39+
ghostscriptPDF processing10.0+
imagemagickImage manipulation7.1+
qrencodeQR code generation4.1+
ghGitHub CLI2.39+

Clojure Tools

ToolPurposeConfig
clj-kondoStatic analysis:dev
cljfmtCode formatting:dev
test-runnerTest execution:test
portalData visualization:dev
tools.buildBuild tooling:build
antqDependency management:outdated

Workflow Commands

Basic Development

# Initial setup
make deps              # Install dependencies
make init              # Create project structure

# Development cycle
make repl              # Start development REPL
make test              # Run test suite
make fmt               # Format code
make lint              # Run linter
make check            # Run all checks

Documentation

# Generate documentation assets
make cover            # Create book cover from PDF
make qr               # Generate repository QR code

Version Control

# Setup Git hooks
git config core.hooksPath .githooks
chmod +x .githooks/*

Version Requirements

  • Clojure 1.11.1+
  • tools.deps 0.16.1281+
  • ClojureScript 1.12.145+ (for async teasers)

Community Resources

Notes

Each puzzle includes:

  • Original puzzle code
  • Solution and explanation
  • Additional examples and edge cases
  • Related documentation links

References

License

This repository is licensed under the Apache License 2.0. See LICENSE for details.