Higher-Order Perl: Transforming Programs with Programs
Dominus, Mark Jason
In stock
Regular price
30.500 KD
inc. VAT
Couldn't load pickup availability
Table of contents
- COVERCover
- CONTENTSix
- PREFACExv
- CHAPTER 1 RECURSION AND CALLBACK1
- 1.1 DECIMAL TO BINARY CONVERSION1
- 1.2 FACTORIAL3
- 1.2.1 Why Private Variables Are Important5
- 1.3 THE TOWER OF HANOI6
- 1.4 HIERARCHICAL DATA12
- 1.5 APPLICATIONS AND VARIATIONS OF DIRECTORY WALKING16
- 1.6 FUNCTIONAL VERSUS OBJECT-ORIENTED PROGRAMMING25
- 1.7 HTML26
- 1.7.1 More Flexible Selection32
- 1.8 WHEN RECURSION BLOWS UP33
- 1.8.1 Fibonacci Numbers33
- 1.8.2 Partitioning35
- CHAPTER 2 DISPATCH TABLES41
- 2.1 CONFIGURATION FILE HANDLING41
- 2.1.1 Table-Driven Configuration43
- 2.1.2 Advantages of Dispatch Tables45
- 2.1.3 Dispatch Table Strategies49
- 2.1.4 Default Actions52
- 2.2 CALCULATOR54
- 2.2.1 HTML Processing Revisited59
- CHAPTER 3 CACHING AND MEMOIZATION63
- 3.1 CACHING FIXES RECURSION65
- 3.2 INLINE CACHING66
- 3.2.1 Static Variables67
- 3.3 GOOD IDEAS68
- 3.4 MEMOIZATION69
- 3.5 THE MEMOIZE MODULE70
- 3.5.1 Scope and Duration71
- 3.5.2 Lexical Closure76
- 3.5.3 Memoization Again79
- 3.6 CAVEATS80
- 3.6.1 Functions Whose Return Values Do Not Depend on Their Arguments80
- 3.6.2 Functions with Side Effects80
- 3.6.3 Functions That Return References81
- 3.6.4 A Memoized Clock?82
- 3.6.5 Very Fast Functions83
- 3.7 KEY GENERATION84
- 3.7.1 More Applications of User-Supplied Key Generators89
- 3.7.2 Inlined Cache Manager with Argument Normalizer90
- 3.7.3 Functions with Reference Arguments93
- 3.7.4 Partitioning93
- 3.7.5 Custom Key Generation for Impure Functions94
- 3.8 CACHING IN OBJECT METHODS96
- 3.8.1 Memoization of Object Methods99
- 3.9 PERSISTENT CACHES100
- 3.10 ALTERNATIVES TO MEMOIZATION101
- 3.11 EVANGELISM108
- 3.12 THE BENEFITS OF SPEED109
- 3.12.1 Profiling and Performance Analysis110
- 3.12.2 Automatic Profiling111
- 3.12.3 Hooks113
- CHAPTER 4 ITERATORS115
- 4.1 INTRODUCTION115
- 4.1.1 Filehandles Are Iterators115
- 4.1.2 Iterators Are Objects117
- 4.1.3 Other Common Examples of Iterators118
- 4.2 HOMEMADE ITERATORS119
- 4.2.1 A Trivial Iterator: upto()121
- 4.2.2 dir_walk()123
- 4.2.3 On Clever Inspirations124
- 4.3 EXAMPLES126
- 4.3.1 Permutations128
- 4.3.2 Genomic Sequence Generator135
- 4.3.3 Filehandle Iterators139
- 4.3.4 A Flat-File Database140
- 4.3.5 Searching Databases Backwards148
- 4.3.6 Random Number Generation153
- 4.4 FILTERS AND TRANSFORMS157
- 4.4.1 imap()158
- 4.4.2 igrep()160
- 4.4.3 list_iterator()161
- 4.4.4 append()162
- 4.5 THE SEMIPREDICATE PROBLEM163
- 4.5.1 Avoiding the Problem164
- 4.5.2 Alternative undefs166
- 4.5.3 Rewriting Utilities169
- 4.5.4 Iterators That Return Multiple Values170
- 4.5.5 Explicit Exhaustion Function171
- 4.5.6 Four-Operation Iterators173
- 4.5.7 Iterator Methods176
- 4.6 ALTERNATIVE INTERFACES TO ITERATORS177
- 4.6.1 Using foreach to Loop Over More Than One Array177
- 4.6.2 An Iterator with an each-Like Interface182
- 4.6.3 Tied Variable Interfaces184
- 4.7 AN EXTENDED EXAMPLE: WEB SPIDERS187
- 4.7.1 Pursuing Only Interesting Links190
- 4.7.2 Referring URLs192
- 4.7.3 robots.txt197
- 4.7.4 Summary200
- CHAPTER 5 FROM RECURSION TO ITERATORS203
- 5.1 THE PARTITION PROBLEM REVISTED204
- 5.1.1 Finding All Possible Partitions206
- 5.1.2 Optimizations209
- 5.1.3 Variations212
- 5.2 HOW TO CONVERT A RECURSIVE FUNCTION TO AN ITERATOR215
- 5.3 A GENERIC SEARCH ITERATOR225
- 5.4 OTHER GENERAL TECHNIQUES FOR ELIMINATING RECURSION229
- 5.4.1 Tail-Call Elimination229
- 5.4.2 Creating Tail Calls239
- 5.4.3 Explicit Stacks242
- CHAPTER 6 INFINITE STREAMS255
- 6.1 LINKED LISTS256
- 6.2 LAZY LINKED LISTS257
- 6.2.1 A Trivial Stream: upto()259
- 6.2.2 Utilities for Streams260
- 6.3 RECURSIVE STREAMS263
- 6.3.1 Memoizing Streams265
- 6.4 THE HAMMING PROBLEM269
- 6.5 REGEX STRING GENERATION272
- 6.5.1 Generating Strings in Order283
- 6.5.2 Regex Matching286
- 6.5.3 Cutsorting288
- 6.6 THE NEWTON-RAPHSON METHOD300
- 6.6.1 Approximation Streams304
- 6.6.2 Derivatives305
- 6.6.3 The Tortoise and the Hare308
- 6.6.4 Finance310
- 6.7 POWER SERIES313
- 6.7.1 Derivatives319
- 6.7.2 Other Functions320
- 6.7.3 Symbolic Computation320
- CHAPTER 7 HIGHER-ORDER FUNCTIONS AND CURRYING325
- 7.1 CURRYING325
- 7.2 COMMON HIGHER-ORDER FUNCTIONS333
- 7.2.1 Automatic Currying335
- 7.2.2 Prototypes337
- 7.2.3 More Currying340
- 7.2.4 Yet More Currying342
- 7.3 reduce() AND combine()343
- 7.3.1 Boolean Operators348
- 7.4 DATABASES351
- 7.4.1 Operator Overloading356
- CHAPTER 8 PARSING359
- 8.1 LEXERS359
- 8.1.1 Emulating the <> Operator360
- 8.1.2 Lexers More Generally365
- 8.1.3 Chained Lexers368
- 8.1.4 Peeking374
- 8.2 PARSING IN GENERAL376
- 8.2.1 Grammars376
- 8.2.2 Parsing Grammars380
- 8.3 RECURSIVE-DESCENT PARSERS384
- 8.3.1 Very Simple Parsers384
- 8.3.2 Parser Operators386
- 8.3.3 Compound Operators388
- 8.4 ARITHMETIC EXPRESSIONS390
- 8.4.1 A Calculator400
- 8.4.2 Left Recursion400
- 8.4.3 A Variation on star()408
- 8.4.4 Generic-Operator Parsers412
- 8.4.5 Debugging415
- 8.4.6 The Finished Calculator424
- 8.4.7 Error Diagnosis and Recovery427
- 8.4.8 Big Numbers435
- 8.5 PARSING REGEXES435
- 8.6 OUTLINES440
- 8.7 DATABASE-QUERY PARSING448
- 8.7.1 The Lexer448
- 8.7.2 The Parser451
- 8.8 BACKTRACKING PARSERS456
- 8.8.1 Continuations457
- 8.8.2 Parse Streams461
- 8.9 OVERLOADING465
- CHAPTER 9 DECLARATIVE PROGRAMMING471
- 9.1 CONSTRAINT SYSTEMS472
- 9.2 LOCAL PROPAGATION NETWORKS472
- 9.2.1 Implementing a Local Propagation Network475
- 9.2.2 Problems with Local Propagation487
- 9.3 LINEAR EQUATIONS488
- 9.4 linogram: A DRAWING SYSTEM490
- 9.4.1 Equations500
- 9.4.2 Values514
- 9.4.3 Feature Types530
- 9.4.4 The Parser539
- 9.4.5 Missing Features560
- 9.5 CONCLUSION563
- INDEX565
- FUNCTION INDEX575
Book details
- Vendor Elsevier S & T
- SKU 9781558607019
- ISBN-13 9780080478340
- Author Dominus, Mark Jason
- Category Computers
- Subject General
Do you have questions about this book?
Most Perl programmers were originally trained as C and Unix programmers, so the Perl programs that they write bear a strong resemblance to C programs. However, Perl incorporates many features that have their roots in other languages such as Lisp. These advanced features are not well understood and are rarely used by most Perl programmers, but they are very powerful. They can automate tasks in everyday programming that are difficult to solve in any other way. One of the most powerful of these techniques is writing functions that manufacture or modify other functions. For example, instead of writing ten similar functions, a programmer can write a general pattern or framework that can then create the functions as needed according to the pattern. For several years Mark Jason Dominus has worked to apply functional programming techniques to Perl. Now Mark brings these flexible programming methods that he has successfully taught in numerous tutorials and training sessions to a wider audience.
* Introduces powerful programming methodsnew to most Perl programmersthat were previously the domain of computer scientists
* Gradually builds up confidence by describing techniques of progressive sophistication
* Shows how to improve everyday programs and includes numerous engaging code examples to illustrate the methods
* Introduces powerful programming methodsnew to most Perl programmersthat were previously the domain of computer scientists
* Gradually builds up confidence by describing techniques of progressive sophistication
* Shows how to improve everyday programs and includes numerous engaging code examples to illustrate the methods
Instant delivery by email
Your access email arrives within minutes of checkout, with a sign-in link for each book — no shipping, no waiting.
Read on any device
Books open in VitalSource Bookshelf on your phone, tablet, or computer, online or offline. Your library is always available at aafaq.vitalsource.com — just log in with the email you used at checkout.
Lost the email?
Resend it to yourself in seconds from My eBook orders, or email cs@aafaqeducation.com and we'll help.