Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Praise for Higher-Order Perl ...
Dedication
Preface
Web Site
Acknowledgements
1. Recursion and Callbacks
1.1 Decimal to Binary Conversion
1.2 Factorial
1.2.1 Why Private Variables Are Important
1.3 The Tower of Hanoi
1.4 Hierarchical Data
1.5 Applications and Variations of Directory Walking
1.6 Functional Versus Object Oriented Programming
1.7 HTML
1.7.1 More Flexible Selection
1.8 When Recursion Blows Up
1.8.1 Fibonacci Numbers
1.8.2 Partitioning
2. Dispatch Tables
2.1 Configuration File Handling
2.1.1 Table-Driven Configuration
2.1.2 Advantages of Dispatch Tables
2.1.3 Dispatch Table Strategies
2.1.4 Default Actions
2.2 Calculator
2.2.1 HTML Processing Revisited
3. Memoization
3.1 Caching Fixes Recursion
3.2 Inline Caching
3.2.1 Static Variables
3.3 Good Ideas
3.4 Memoization
3.5 The Memoize Module
3.5.1 Scope and Duration
Scope
Duration
3.5.2 Lexical Closure
3.5.3 Memoization Again
3.6 Caveats
3.6.1 Functions Whose Return Values Do Not Depend on Their Arguments
3.6.2 Functions with Side Effects
3.6.3 Functions That Return References
3.6.4 A Memoized Clock?
3.6.5 Very Fast Functions
3.7 Key Generation
3.7.1 More Applications of User-Supplied Key Generators
3.7.2 Inlined Cache Manager with Argument Normalizer
3.7.3 Functions with Reference Arguments
3.7.4 Partitioning
3.7.5 Custom Key Generation for Impure Functions
3.8 Caching in Object Methods
3.8.1 Memoization of Object Methods
3.9 Persistent Caches
3.10 Alternatives to Memoization
3.11 Evangelism
3.12 The Benefits of Speed
3.12.1 Profiling and Performance Analysis
3.12.2 Automatic Profiling
3.12.3 Hooks
4. Iterators
4.1 Introduction
4.1.1 Filehandles Are Iterators
4.1.2 Iterators Are Objects
4.1.3 Other Common Examples of Iterators
4.2 Homemade Iterators
4.2.1 A Trivial Iterator: upto()
Syntactic Sugar for Manufacturing Iterators
4.2.2 dir_walk()
4.2.3 On Clever Inspirations
4.3 Examples
4.3.1 Permutations
4.3.2 Genomic Sequence Generator
4.3.3 Filehandle Iterators
4.3.4 A Flat-File Database
Improved Database
4.3.5 Searching Databases Backwards
A Query Package That Transforms Iterators
An Iterator That Reads Files Backwards
Putting it Together
4.3.6 Random Number Generation
4.4 Filters and Transforms
4.4.1 imap()
4.4.2 igrep()
4.4.3 list_iterator()
4.4.4 append()
4.5 The Semipredicate Problem
4.5.1 Avoiding the Problem
4.5.2 Alternative undefs
4.5.3 Rewriting Utilities
4.5.4 Iterators That Return Multiple Values
4.5.5 Explicit Exhaustion Function
4.5.6 Four-Operation Iterators
4.5.7 Iterator Methods
4.6 Alternative Interfaces to Iterators
4.6.1 Using foreach to Loop Over More Than One Array
4.6.2 An Iterator with an each-Like Interface
4.6.3 Tied Variable Interfaces
Summary of tie
Tied Scalars
Tied Filehandles
4.7 An Extended Example: Web Spiders
4.7.1 Pursuing Only Interesting Links
4.7.2 Referring URLs
4.7.3 robots.txt
4.7.4 Summary
5. From Recursion to Iterators
5.1 The Partition Problem Revisited
5.1.1 Finding All Possible Partitions
5.1.2 Optimizations
5.1.3 Variations
5.2 How to Convert a Recursive Function to an Iterator
5.3 A Generic Search Iterator
5.4 Other General Techniques for Eliminating Recursion
5.4.1 Tail-Call Elimination
Someone Else´s Problem
5.4.2 Creating Tail Calls
5.4.3 Explicit Stacks
Eliminating Recursion From fib()
6. Infinite Streams
6.1 Linked Lists
6.2 Lazy Linked Lists
6.2.1 A Trivial Stream: upto()
6.2.2 Utilities for Streams
6.3 Recursive Streams
6.3.1 Memoizing Streams
6.4 The Hamming Problem
6.5 Regex String Generation
6.5.1 Generating Strings in Order
6.5.2 Regex Matching
6.5.3 Cutsorting
Log Files
6.6 The Newton-Raphson Method
6.6.1 Approximation Streams
6.6.2 Derivatives
6.6.3 The Tortoise and the Hare
6.6.4 Finance
6.7 Power Series
6.7.1 Derivatives
6.7.2 Other Functions
6.7.3 Symbolic Computation
7. Higher-Order Functions and Currying
7.1 Currying
7.2 Common Higher-Order Functions
7.2.1 Automatic Currying
7.2.2 Prototypes
Prototype Problems
7.2.3 More Currying
7.2.4 Yet More Currying
7.3 reduce() and combine()
7.3.1 Boolean Operators
7.4 Databases
7.4.1 Operator Overloading
8. Parsing
8.1 Lexers
8.1.1 Emulating the <> Operator
8.1.2 Lexers More Generally
8.1.3 Chained Lexers
8.1.4 Peeking
8.2 Parsing in General
8.2.1 Grammars
8.2.2 Parsing Grammars
8.3 Recursive-Descent Parsers
8.3.1 Very Simple Parsers
8.3.2 Parser Operators
8.3.3 Compound Operators
8.4 Arithmetic Expressions
8.4.1 A Calculator
8.4.2 Left Recursion
8.4.3 A Variation on star()
8.4.4 Generic-Operator Parsers
8.4.5 Debugging
8.4.6 The Finished Calculator
8.4.7 Error Diagnosis and Recovery
Error-Recovery Parsers
Exceptions
8.4.8 Big Numbers
8.5 Parsing Regexes
8.6 Outlines
8.7 Database-Query Parsing
8.7.1 The Lexer
8.7.2 The Parser
8.8 Backtracking Parsers
8.8.1 Continuations
8.8.2 Parse Streams
8.9 Overloading
9. Declarative Programming
9.1 Constraint Systems
9.2 Local Propagation Networks
9.2.1 Implementing a Local Propagation Network
9.2.2 Problems with Local Propagation
9.3 Linear Equations
9.4 linogram: A Drawing System
9.4.1 Equations
ref($base) || $base
Solving Equations
Constraints
9.4.2 Values
Constant Values
Tuple Values
Feature Values
Intrinsic Constraints
Synthetic Constraints
Feature-Value Methods
9.4.3 Feature Types
Scalar Types
Type Methods
9.4.4 The Parser
Parser Extensions
%TYPES
Programms
Definitions
Declarations
Expressions
Missing Features
Conclusion
Footnotes
Chapter 1
Chapter 3
Chapter 4
Chapter 5
Chapter 6
Chapter 7
Chapter 8
Chapter 9
Errata
← Prev
Back
Next →
← Prev
Back
Next →