Muutke küpsiste eelistusi

Common Lisp Recipes: A Problem-Solution Approach 1st ed. [Pehme köide]

  • Formaat: Paperback / softback, 744 pages, kõrgus x laius: 254x178 mm, 598 Illustrations, black and white; XXVII, 744 p. 598 illus., 1 Paperback / softback
  • Ilmumisaeg: 31-Dec-2015
  • Kirjastus: APress
  • ISBN-10: 1484211774
  • ISBN-13: 9781484211779
Teised raamatud teemal:
  • Pehme köide
  • Hind: 95,02 €*
  • * hind on lõplik, st. muud allahindlused enam ei rakendu
  • Tavahind: 111,79 €
  • Säästad 15%
  • Raamatu kohalejõudmiseks kirjastusest kulub orienteeruvalt 2-4 nädalat
  • Kogus:
  • Lisa ostukorvi
  • Tasuta tarne
  • Tellimisaeg 2-4 nädalat
  • Lisa soovinimekirja
  • Formaat: Paperback / softback, 744 pages, kõrgus x laius: 254x178 mm, 598 Illustrations, black and white; XXVII, 744 p. 598 illus., 1 Paperback / softback
  • Ilmumisaeg: 31-Dec-2015
  • Kirjastus: APress
  • ISBN-10: 1484211774
  • ISBN-13: 9781484211779
Teised raamatud teemal:
Find solutions to problems and answers to questions you are likely to encounter when writing real-world applications in Common Lisp. This book covers areas as diverse as web programming, databases, graphical user interfaces, integration with other programming languages, multi-threading, and mobile devices as well as debugging techniques and optimization, to name just a few. 

Written by an author who has used Common Lisp in many successful commercial projects over more than a decade, Common Lisp Recipes is also the first Common Lisp book to tackle such advanced topics as environment access, logical pathnames, Gray streams, delivery of executables, pretty printing, setf expansions, or changing the syntax of Common Lisp.





The book is organized around specific problems or questions each followed by ready-to-use example solutions and clear explanations of the concepts involved, plus pointers to alternatives and more information. Each recipe can be read independently of the others and thus the book will earn a special place on your bookshelf as a reference work you always want to have within reach.





Common Lisp Recipes is aimed at programmers who are already familiar with Common Lisp to a certain extent but do not yet have the experience you typically only get from years of hacking in a specific computer language. It is written in a style that mixes hands-on no-frills pragmatism with precise information and prudent mentorship.





If you feel attracted to Common Lisp's mix of breathtaking features and down-to-earth utilitarianism, you'll also like this book.
About the Author xvii
About the Technical Reviewer xix
Preface xxi
Who This Book Is For xxi
Who This Book Is (Probably) Not For xxii
How to Read This Book xxii
What's In and What Not xxiii
The HyperSpec xxiv
Which Implementation xxiv
Source Code xxv
The Index xxv
Typographical Conventions xxv
Acknowledgements xxvi
1 Symbols and Packages
1(30)
1-1 Understanding the Role of Packages and the Symbol Nomenclature
1(4)
1-2 Making Unique Symbols
5(4)
1-3 Making Symbols Inaccessible
9(3)
How Can We Fix This?
11(1)
1-4 Avoiding Name Conflicts
12(3)
When Name Conflicts Do Not Occur
15(1)
1-5 Using Symbols As Stand-Ins for Arbitrary Forms
15(2)
1-6 Searching for Symbols by Name
17(2)
1-7 Iterating Through All Symbols of a Package
19(2)
What To Do If You Don't Like LOOP
20(1)
1-8 Understanding Common Lisp's Case (In)Sensitivity
21(5)
Style Hint: Don't Use CamelCase!
25(1)
1-9 Using Symbols As String Substitutes
26(2)
So, What Should You Use?
27(1)
1-10 "Overloading" of Standard Common Lisp Operators
28(3)
2 Conses, Lists, and Trees
31(30)
2-1 Understanding Conses
31(6)
List Access
34(1)
Testing Whether Something Is a Cons or a List
35(2)
2-2 Creating Lists
37(2)
Converting Vectors to Lists
38(1)
2-3 Transposing a Matrix
39(1)
2-4 Using List Interpolation
40(2)
2-5 Adding Objects to the End of a List
42(3)
The Tail Wagging the List
44(1)
2-6 "Splicing" into a List
45(4)
2-7 Detecting Shared Structure in Lists
49(2)
Isolating the Non-Shared Part
51(1)
2-8 Working with Trees
51(4)
More Complicated Trees
54(1)
Common Lisp's Standard Tree Functions
55(1)
2-9 Working with Stacks
55(1)
2-10 Implementing a Queue
56(2)
2-11 Destructuring and Pattern Matching
58(3)
3 Strings and Characters
61(26)
3-1 Getting the ASCII Code of a Character
61(2)
The Other Way Around
63(1)
The Limit
63(1)
3-2 Naming Characters
63(2)
3-3 Using Different Character Encodings
65(2)
3-4 Comparing Strings or Characters
67(4)
Internationalization
70(1)
3-5 Escaping Characters in String Literals and Variable Interpolation
71(1)
Is It Still a Literal?
72(1)
3-6 Controlling Case
72(3)
What About Unicode?
74(1)
3-7 Accessing or Modifying a Substring
75(2)
3-8 Finding a Character or a Substring Within a String
77(1)
3-9 Trimming Strings
77(2)
3-10 Processing a String One Character at a Time
79(2)
3-11 Joining Strings
81(2)
3-12 Reading CSV Data
83(4)
4 Numbers and Math
87(30)
4-1 Using Arbitrarily Large Integers
87(2)
4-2 Understanding Fixnums
89(3)
4-3 Performing Modular Arithmetic
92(2)
Efficiency Considerations
93(1)
4-4 Switching Bases
94(2)
4-5 Performing Exact Arithmetic with Rational Numbers
96(6)
Various Ways of Converting Numbers to Integers
98(1)
How Not to Use FLOOR and Friends
99(1)
Converting Floating-Point Numbers to Rationals and Vice Versa
99(2)
Mixing Rationals and Floats
101(1)
4-6 Controlling the Default Float Format
102(2)
4-7 Employing Arbitrary Precision Floats
104(2)
4-8 Working with Complex Numbers
106(3)
4-9 Parsing Numbers
109(2)
4-10 Testing Whether Two Numbers Are Equal
111(2)
Don't Ever Use EQ with Numbers!
112(1)
4-11 Computing Angles Correctly
113(2)
4-12 Calculating Exact Square Roots
115(2)
5 Arrays and Vectors
117(20)
5-1 Working with Multiple Dimensions
117(2)
5-2 Understanding Vectors and Simple Arrays
119(1)
5-3 Obtaining the Size of an Array
120(1)
5-4 Providing Initial Contents
121(2)
A Warning About Identical Objects
122(1)
5-5 Treating Arrays As Vectors
123(2)
5-6 Making the Length of Vectors Flexible
125(2)
5-7 Adjusting Arrays
127(2)
5-8 Using an Array As a "Window" into Another Array
129(2)
5-9 Restricting the Element Type of an Array
131(3)
Upgrading Element Types
133(1)
5-10 Copying an Array
134(3)
A Warning About Object Identity
135(2)
6 Hash Tables, Maps, and Sets
137(34)
6-1 Understanding the Basics of Hash Tables
137(3)
Why Does GETHASH Return Two Values?
139(1)
How Many Entries Does the Hash Table Have?
140(1)
6-2 Providing Default Values For Hash Table Lookups
140(2)
6-3 Removing Hash Table Entries
142(1)
6-4 Iterating Through a Hash Table
143(5)
Don't Rely on Any Order!
146(1)
Don't Modify While You're Iterating!
147(1)
Can't This Be More Concise, Please?
147(1)
6-5 Understanding Hash Table Tests and Defining Your Own
148(4)
What Is SXHASH For?
152(1)
6-6 Controlling Hash Table Growth
152(3)
6-7 Getting Rid of Hash Table Entries Automatically
155(3)
6-8 Representing Maps As Association Lists
158(5)
Combining Lookup and Manipulation
161(1)
Why Would Anybody Prefer Alists over Hash Tables?
162(1)
6-9 Representing Maps As Property Lists
163(3)
When to Prefer Plists over Alists
165(1)
The Plist of a Symbol
166(1)
6-10 Working with Sets
166(5)
Representing Sets As Hash Tables
169(1)
Representing Sets As Bit Patterns
169(2)
7 Sequences and Iteration
171(32)
7-1 Filtering a Sequence
171(1)
7-2 Searching a Sequence
172(3)
7-3 Sorting and Merging Sequences
175(2)
7-4 Mixing Different Sequence Types
177(1)
7-5 Re-Using a Part of a Sequence
177(2)
7-6 Repeating Some Values Cyclically
179(3)
Alternatives
181(1)
7-7 Counting Down
182(2)
7-8 Iterating over "Chunks" of a List
184(2)
7-9 Closing over Iteration Variables
186(1)
7-10 "Extending" Short Sequences in Iterations
187(1)
7-11 Breaking out of LOOP
188(3)
7-12 Making Sense of the MAP ... Zoo
191(3)
The Sequence Variants
194(1)
7-13 Defining Your Own Sequence Types
194(2)
7-14 Iterating with Iterate
196(4)
7-15 Iterating with Series
200(3)
What the Example Does
201(2)
8 The Lisp Reader
203(28)
8-1 Employing the Lisp Reader for Your Own Code
203(3)
Why READ Is Potentially Dangerous
205(1)
What READ Doesn't Do
205(1)
The Optional Arguments to READ
206(1)
Go Wild!
206(1)
8-2 Troubleshooting Literal Object Notation
206(2)
This Also Applies to Strings!
208(1)
8-3 Evaluating Forms at Read Time
208(3)
What to Look Out For
210(1)
Alternatives
210(1)
8-4 Embedding Literal Arrays into Your Code
211(2)
The Usual Warning
212(1)
8-5 Understanding the Different Ways to Refer to a Function
213(1)
8-6 Repeating Something You Already Typed
214(2)
They Don't Only Look Identical, They Are Identical!
216(1)
8-7 Safely Experimenting with Read tables
216(3)
Temporarily Switching to Standard IO Syntax
218(1)
8-8 Changing the Syntax Type of a Character
219(4)
The Six Syntax Types
220(2)
How to Actually Change the Syntax Type
222(1)
Some Things Never Change
222(1)
8-9 Creating Your Own Reader Macros
223(3)
What Reader Macro Functions Do
224(2)
8-10 Working with Dispatching Macro Characters
226(2)
8-11 Preserving Whitespace
228(3)
9 Printing
231(34)
9-1 Using the Printing Primitives
231(6)
Printing Objects So That They Can Be Read Back in Again
235(1)
Shortcuts
236(1)
9-2 Printing to and into Strings
237(2)
9-3 Printing NIL As a List
239(1)
9-4 Extending FORMAT Control Strings Over More Than One Line
240(1)
9-5 Using Functions As FORMAT Controls
241(2)
9-6 Creating Your Own FORMAT Directives
243(2)
9-7 Recursive Processing of FORMAT Controls
245(2)
9-8 Controlling How Your Own Objects Are Printed
247(2)
9-9 Controlling the Pretty Printer
249(4)
9-10 Printing Long Lists
253(4)
9-11 Pretty-Printing Compound Objects
257(5)
Using the Pretty Printer from FORMAT
260(2)
9-12 Modifying the Pretty Printer
262(3)
10 Evaluation, Compilation, Control Flow
265(38)
10-1 Comparing Arbitrary Lisp Objects
265(4)
Comparing State
266(3)
Constants
269(1)
10-2 Using Constant Variables as Keys in CASE Macros
269(2)
10-3 Using Arbitrary Variable Names for Keyword Parameters
271(2)
Keyword Names Don't Have to Be Keywords
272(1)
Keyword Dames Don't Have to Be Constant
273(1)
10-4 Creating "Static Local Variables," Like in C
273(2)
10-5 "Preponing" the Computation of Values
275(3)
10-6 Modifying the Behavior of Functions You Don't Have the Source Of
278(2)
10-7 Swapping the Values of Variables (or Places)
280(3)
10-8 Creating Your Own Update Forms for "Places"
283(11)
Using DEFSETF
285(1)
Using DEFINE--SETF--EXPANDER
286(5)
So, Which One Do I Use?
291(1)
Using DEFINE--MODIFY--MACRO
291(2)
Multiple-Valued Places
293(1)
10-9 Working with Environments
294(5)
10-10 Commenting Out Parts of Your Code
299(4)
Some Notes About; and #I
302(1)
How;, #I, and Others Are Implemented
302(1)
11 Concurrency
303(30)
11-1 Managing Lisp Processes
304(4)
Escape Hatches
307(1)
Threads Are Expensive
308(1)
11-2 Accessing Shared Resources Concurrently
308(9)
Locks
312(1)
Atomic Operations
313(1)
More Problems
314(3)
11-3 Using Special Variables in Concurrent Programs
317(3)
Per-Thread Initial Bindings
319(1)
Variables That Are Always Global
319(1)
11-4 Communicating with Other Threads
320(2)
Alternatives
322(1)
11-5 Parallelizing Algorithms Without Threads and Locks
322(8)
What the Example Does
325(1)
Fine-Tuning
326(1)
Ptrees
326(4)
Alternatives
330(1)
11-6 Determining the Number of Cores
330(3)
12 Error Handling and Avoidance
333(28)
12-1 Checking Types at Run Time
333(3)
Alternatives
335(1)
12-2 Adding Assertions to Your Code
336(2)
Disabling Assertions in "Production Code"
338(1)
12-3 Defining Your Own Conditions
338(3)
How Conditions Are Printed
340(1)
12-4 Signaling a Condition
341(3)
Condition Designators
343(1)
12-5 Handling Conditions
344(6)
Ignoring Errors
349(1)
12-6 Providing and Using Restarts
350(6)
Visible Restarts
354(1)
Predefined Restarts
355(1)
12-7 Getting Rid of Warning Messages
356(1)
12-8 Protecting Code from Non-Local Exits
357(4)
"WITH--" Macros
360(1)
13 Objects, Classes, Types
361(36)
13-1 Defining Types
361(5)
Compound Type Specifiers
363(2)
Derived Types
365(1)
13-2 Using Classes As Types
366(1)
13-3 Writing Methods for Built-In Classes
367(2)
13-4 Providing Constructors for Your Classes
369(3)
13-5 Marking Slots As "Private"
372(2)
13-6 Changing the Argument Precedence Order
374(2)
13-7 Automatically Initializing Slots on First Usage
376(1)
13-8 Changing and Redefining Classes on the Fly
377(6)
Objects Changing Their Class
380(1)
Redefining Classes
381(2)
13-9 Making Your Objects Externalizable
383(2)
13-10 Using and Defining Non-Standard Method Combinations
385(6)
Rolling Your Own
388(1)
Arbitrarily Complex Method Combinations
389(2)
13-11 Extending and Modifying CLOS
391(6)
What the example does
393(4)
14 I/O: Streams and Files
397(38)
14-1 Redirecting Streams
397(3)
Other Ways to Do It
398(1)
Synonym Streams
399(1)
14-2 Flushing an Output Stream
400(1)
14-3 Determining the Size of a File
401(1)
14-4 Reading a Whole File at Once
402(2)
Alternatives
404(1)
14-5 Sending Data to Two Streams in Parallel
404(3)
Synonym Streams
406(1)
14-6 Sending Data to "/dev/null"
407(1)
14-7 Pretending a String Is a Stream
408(3)
More Details
410(1)
14-8 Concatenating Streams
411(1)
14-9 Processing Text Files Line by Line
412(3)
What Happens at the End of a Line?
413(1)
What Happens at the End of the File?
414(1)
14-10 Working with Binary Data
415(3)
Reading or Writing Several Bytes at Once
416(1)
You Might Get Bigger Chunks Than You Asked For
417(1)
14-11 Reading "Foreign" Binary Data
418(4)
Floating-Point Values
421(1)
14-12 Using Random Access I/O
422(3)
Different Characters May Have Different Lengths
424(1)
14-13 Serializing Lisp Objects
425(5)
Shared Structure
427(1)
Is It Readable?
428(1)
Can This Be Done Faster, Please?
429(1)
What About JSON or Other Formats?
430(1)
14-14 Customizing Stream Behavior
430(5)
15 Pathnames, Files, Directories
435(34)
15-1 Getting and Setting the Current Directory
435(2)
Shortcuts and Deviations
437(1)
15-2 Testing Whether a File Exists
437(2)
What About Directories?
439(1)
15-3 Creating a Directory
439(3)
Implementation-Specific Alternatives
441(1)
What Might Go Wrong
441(1)
15-4 Finding Files Matching a Pattern
442(3)
15-5 Splitting a Filename into its Component Parts
445(2)
15-6 Renaming a File
447(3)
Implementation-Specific Alternatives
449(1)
Don't Expect "Move" Behavior!
449(1)
15-7 Deleting a File
450(2)
What Does "Success" Mean Anyway?
451(1)
15-8 Deleting a Directory
452(1)
15-9 Copying a File
453(1)
15-10 Processing the Contents of a Directory Recursively
454(2)
The CL-FAD Library
455(1)
15-11 Getting the Pathname a Stream Is Associated With
456(1)
15-12 Dealing with Symbolic Links
457(2)
What If I Want the Symlinks?
459(1)
15-13 Navigating a Directory Tree
459(2)
15-14 Figuring Out (Source) File Locations Programmatically
461(2)
15-15 Understanding Logical Pathnames
463(6)
What Exactly Are Logical Pathnames?
467(1)
So, Maybe Logical Pathnames Aren't Totally Useless
467(2)
16 Developing and Debugging
469(34)
16-1 Embracing Lisp's Image-Based Development Style
469(2)
The Role of the Source Code
471(1)
16-2 Deciding Which IDE to Use
471(4)
A Brief History of Emacs (As Seen from Lisp)
474(1)
Alternatives (?)
475(1)
16-3 Debugging with the Debugger
475(6)
Entering the Debugger Intentionally
478(1)
Without SLIME
479(1)
Logging Backtraces
480(1)
16-4 Tracing Functions
481(3)
Graphical Tracing
483(1)
16-5 Stepping Through Your Code
484(2)
16-6 Acquiring Information About Functions, Macros, and Variables
486(3)
Accessing the HyperSpec
488(1)
Cross-Reference Information
489(1)
16-7 Inspecting and Modifying (Compound) Objects
489(3)
The SLIME Inspector
492(1)
16-8 Browsing Your Lisp Image
492(2)
Alternatives
493(1)
16-9 "Undoing" Definitions
494(3)
16-10 Distinguishing Your IDE's Streams
497(2)
16-11 Utilizing the REPL's Memory
499(2)
IDE History Features
500(1)
16-12 Recording Your Work
501(2)
17 Optimization
503(60)
17-1 Understanding the Importance of the Right Algorithms
504(1)
17-2 Deciding If and Where to Optimize
505(10)
Instrumentation
508(2)
Statistical Profiling
510(2)
Some Things Cannot Be Profiled
512(1)
Where to Go From Here
512(1)
A Warning About Empirical Data
513(1)
What Does TIME Do?
513(1)
CPUs Can Deceive You
513(2)
17-3 Asking the Compiler to Optimize
515(3)
Implementation-Defined Optimize Qualities
517(1)
Can I Have This Global, Please?
517(1)
Compilers Aren't Wizards
518(1)
17-4 Obtaining Optimization Hints from the Compiler
518(4)
17-5 Helping the Compiler by Providing Type Information
522(7)
Generic Operations
525(1)
Boxing
525(1)
How to Declare Types
526(1)
The Scope of Type Declarations
527(1)
Declaring the Return Type of Forms
528(1)
Type Inference
528(1)
Pitfalls
529(1)
17-6 Reducing "Consing"
529(7)
"Consing" and the Heap
532(1)
Reusing Data Structures
533(1)
Destructive Functions
534(1)
"Hidden" Consing
535(1)
"Tuning" the Garbage Collector
536(1)
17-7 Using the Stack Instead of the Heap
536(6)
Multiple Values
540(2)
17-8 Optimizing Recursive Functions
542(2)
17-9 Helping the Compiler with Alternative Implementation Strategies
544(3)
17-10 Avoiding Repeated Computations
547(2)
17-11 Avoiding Function Calls
549(4)
Alternatives That Aren't Really Alternatives
553(1)
The Notinline Declaration and Compiler Macros
553(1)
17-12 Utilizing the Disassembler
553(3)
17-13 Switching to Machine Code
556(2)
Inline Assembly Code
557(1)
17-14 Optimizing Array Access
558(2)
17-15 Comparing Different Implementations
560(3)
18 Libraries
563(28)
18-1 Organizing Your Code
563(6)
Components
564(1)
Dependencies
565(2)
How Does ASDF Find System Definitions?
567(1)
Additional Information
568(1)
What About the Names?
568(1)
Advanced Usage of ASDF
568(1)
18-2 Employing Open Source Libraries
569(2)
Installing Quicklisp
570(1)
Using Quicklisp for Your Own Code
571(1)
18-3 Creating a Project's Skeleton Automatically
571(1)
18-4 Avoiding Wheel-Reinvention
572(2)
18-5 Using Libraries to Write Portable Code
574(2)
18-6 Utilizing Regular Expressions
576(5)
Regex Syntax
577(1)
Scanners
578(1)
Convenience Features
579(2)
Modifying and Dissecting Strings
581(1)
More Information
581(1)
18-7 Obtaining Data via HTTP
581(3)
Parsing HTML
583(1)
18-8 Creating Dynamic Web Sites with Lisp
584(7)
Generating HTML
588(1)
Web Frameworks
589(2)
19 Interfacing with Other Languages
591(46)
19-1 Calling C Functions from Lisp
592(8)
How the FFI Finds and Loads Shared Libraries
594(2)
How the FFI Calls C Functions
596(2)
How the FFI Converts Between C and Lisp Types
598(1)
The "stdcall Problem"
599(1)
19-2 Working with C Pointers
600(4)
Typed Pointers
602(2)
19-3 Accessing and Generating C Arrays
604(3)
Giving C Access to Lisp Arrays
606(1)
19-4 Handling C Structs and Unions
607(4)
Passing Structs by Value
611(1)
19-5 Converting Between Lisp and C Strings
611(3)
19-6 Calling Lisp Functions from C
614(1)
19-7 Generating FFI Code Automatically
615(2)
19-8 Embedding C in Common Lisp
617(1)
19-9 Calling C++ from Lisp
618(4)
Automating the Process
620(2)
ECL and Clasp
622(1)
19-10 Using Java from Lisp
622(6)
Alternatives
625(3)
19-11 Reading and Writing JSON
628(3)
19-12 Reading and Writing XML
631(3)
19-13 Using Prolog from Common Lisp
634(3)
20 Graphical User Interfaces
637(24)
20-1 Using a Web Browser as the GUI for Your Lisp Program
638(4)
What the Example Does
641(1)
20-2 Building Applications with the "Lisp Toolkit"
642(4)
What the Example Does
645(1)
20-3 Creating Common Lisp GUIs Through Java
646(6)
What the Example Does
648(1)
A Better Example
648(4)
20-4 Using CAPI to Build Graphical User Interfaces
652(5)
What the Example Does
655(2)
20-5 Using Lisp on Mobile Devices
657(4)
Alternatives
660(1)
21 Persistence
661(16)
21-1 Serializing Your Data
662(2)
21-2 Accessing Relational Databases
664(4)
21-3 Keeping Your Database in RAM
668(4)
21-4 Using a Lisp Object Database
672(5)
22 The World Outside
677(32)
22-1 Accessing Environment Variables
677(2)
The Windows Registry and Application-Specific Settings
679(1)
22-2 Accessing the Command-Line Arguments
679(1)
22-3 Querying Your Lisp for Information About Its Environment
680(2)
22-4 Delivering Stand-Alone Executables
682(3)
Delivering Programs with the Commercial Lisps
685(1)
22-5 Customizing Your Lisp
685(3)
Saving an Image
687(1)
22-6 Running External Programs
688(4)
22-7 Embedding Lisp
692(4)
Creating Shared Libraries with LispWorks
694(1)
Embedding ABCL in a JAVA Program
695(1)
22-8 Measuring Time
696(2)
22-9 Working with Dates and Times
698(5)
The Local-Time Library
701(2)
22-10 Working with the Garbage Collector
703(6)
Finalizers
705(4)
Index 709
Edmund Weitz is well-known in the Common Lisp community for his open-source libraries and for being one of the organizers of the European Common Lisp Meeting. He has a Ph.D. in mathematics and has been a free-lance Common Lisp consultant for clients in the US, Europe, and Asia since 2002. He now works as a professor for math and computer science at the University of Applied Sciences in Hamburg, Germany.