AgentSkillsCN

Sicp

SICP

SKILL.md

Structure and Interpretation of Computer Programs Skill

Reference for fundamental programming concepts from Abelson and Sussman's "Structure and Interpretation of Computer Programs."

Activation Triggers

Use this skill when discussing:

  • Procedural abstraction and higher-order functions
  • Data abstraction and representation
  • Recursion patterns (tree, tail, mutual)
  • State, assignment, and environment model
  • Streams and lazy evaluation
  • Interpreters and metalinguistic abstraction
  • Compilation and register machines

Quick Reference

Core Abstractions

AbstractionPurposeKey Concept
ProceduralHide implementation detailsBlack-box abstraction
DataSeparate use from representationConstructors/selectors
SyntacticCreate new languagesInterpreters/macros

Higher-Order Function Patterns

PatternDescriptionExample
MapTransform each element(map square list)
FilterSelect matching elements(filter even? list)
Fold/ReduceAccumulate to single value(fold + 0 list)
ComposeCombine functions(compose f g)

Recursion Patterns

PatternCharacteristicsSpace
LinearSingle recursive callO(n)
TailResult in recursive callO(1)
TreeMultiple recursive callsO(depth)
MutualFunctions call each otherVaries

Data Structures

StructureRepresentationOperations
Paircons, car, cdrBasic building block
ListChain of pairsSequence operations
TreeNested pairsHierarchical data
SetList or treeUnion, intersection

Evaluation Models

ModelStateBinding
SubstitutionStatelessDirect replacement
EnvironmentStatefulFrame-based lookup

Stream Operations

OperationBehaviorEvaluation
cons-streamDelay tailLazy
stream-carGet firstImmediate
stream-cdrForce tailOn-demand
stream-mapTransform lazilyLazy
stream-filterSelect lazilyLazy

Directory Structure

code
sicp/
├── SKILL.md
├── procedures/
│   ├── abstraction.md
│   ├── higher-order-functions.md
│   └── recursion-patterns.md
├── data/
│   ├── data-abstraction.md
│   ├── hierarchical-data.md
│   └── symbolic-data.md
├── modularity/
│   ├── assignment-and-state.md
│   ├── environment-model.md
│   └── streams.md
└── metalinguistic/
    ├── interpreters.md
    ├── lazy-evaluation.md
    └── register-machines.md

Usage Examples

Designing Abstractions

code
Question: "How should I structure this complex function?"

Consider:
1. Identify primitive operations
2. Build compound procedures - See procedures/abstraction.md
3. Use higher-order functions - See procedures/higher-order-functions.md
4. Choose appropriate recursion - See procedures/recursion-patterns.md

Managing Complexity

code
Question: "How do I handle growing complexity?"

Consider:
- Data abstraction barriers - See data/data-abstraction.md
- Modularity through state - See modularity/assignment-and-state.md
- Lazy evaluation for infinite data - See modularity/streams.md

Building Languages

code
Question: "Should I create a DSL?"

Consider:
- Interpreter design - See metalinguistic/interpreters.md
- Lazy evaluation semantics - See metalinguistic/lazy-evaluation.md
- Compilation strategies - See metalinguistic/register-machines.md

Based on concepts from "Structure and Interpretation of Computer Programs" by Harold Abelson and Gerald Jay Sussman.