Welcome to Scribd. Sign in or start your free trial to enjoy unlimited e-books, audiobooks & documents.Find out more
Download
Standard view
Full view
of .
Look up keyword or section
Like this
2Activity

Table Of Contents

INTRODUCTION
What Makes Lisp So Cool and Unusual?
If Lisp Is So Great, Why Don’t More People Use It?
Where Did Lisp Come From?
Where Does Lisp Get Its Power?
GETTING STARTED WITH LISP
Lisp Dialects
A Tale of Two Lisps
Up-and-Coming Lisps
Lisp Dialects Used for Scripting
ANSI Common Lisp
Getting Started with CLISP
Installing CLISP
Starting Up CLISP
What You’ve Learned
CREATING YOUR FIRST LISP PROGRAM
The Guess-My-Number Game
Defining Global Variables in Lisp
Defining the small and big Variables
An Alternative Global Variable Definition Function
Basic Lisp Etiquette
Defining Global Functions in Lisp
Defining the guess-my-number Function
Defining the smaller and bigger Functions
Defining the start-over Function
Defining Local Variables in Lisp
Defining Local Functions in Lisp
EXPLORING THE SYNTAX OF LISP CODE
Syntax and Semantics
The Building Blocks of Lisp Syntax
Symbols
Numbers
Strings
How Lisp Distinguishes Between Code and Data
Code Mode
Data Mode
Lists in Lisp
Cons Cells
List Functions
Nested Lists
MAKING DECISIONS WITH CONDITIONS
The Symmetry of nil and ()
Empty Equals False
The Four Disguises of ()
The Conditionals: if and Beyond
One Thing at a Time with if
Going Beyond if: The when and unless Alternatives
The Command That Does It All: cond
Branching with case
Cool Tricks with Conditions
Using the Stealth Conditionals and and or
Using Functions That Return More than Just the Truth
Comparing Stuff: eq, equal, and More
BUILDING A TEXT GAME ENGINE
The Wizard’s Adventure Game
Our Game World
Basic Requirements
Describing the Scenery with an Association List
Describing the Location
Describing the Paths
How Quasiquoting Works
Describing Multiple Paths at Once
Describing Objects at a Specific Location
Listing Visible Objects
Describing Visible Objects
Describing It All
Walking Around in Our World
Picking Up Objects
Checking Our Inventory
Writing a Custom read Function
Writing a game-eval Function
Writing a game-print Function
Dotted Lists
Pairs
Circular Lists
Association Lists
Coping with Complicated Data
Visualizing Tree-like Data
Visualizing Graphs
Creating a Graph
Generating the DOT Information
Turning the DOT File into a Picture
Creating a Picture of Our Graph
Creating Undirected Graphs
THIS AIN’T YOUR DADDY’S WUMPUS
The Grand Theft Wumpus Game
Defining the Edges of Congestion City
Generating Random Edges
Looping with the loop Command
Preventing Islands
Building the Final Edges for Congestion City
Building the Nodes for Congestion City
Initializing a New Game of Grand Theft Wumpus
Drawing a Map of Our City
Drawing a City from Partial Knowledge
Walking Around Town
Let’s Hunt Some Wumpus!
ADVANCED DATATYPES AND GENERIC PROGRAMMING
Arrays
Working with Arrays
Using a Generic Setter
When to Use Structures
Handling Data in a Generic Way
Working with Sequences
Creating Your Own Generic Functions with Type Predicates
The Orc Battle Game
Global Variables for the Player and Monsters
Main Game Functions
Player Management Functions
Helper Functions for Player Attacks
Monster Management Functions
The Monsters
To Battle!
LOOP AND FORMAT: THE SEEDY UNDERBELLY OF LISP
LOOPING WITH THE LOOP COMMAND
The loop Macro
Some loop Tricks
Everything You Ever Wanted to Know About loop
Using loop to Evolve!
Growing Plants in Our World
Creating Animals
Simulating a Day in Our World
Drawing Our World
Creating a User Interface
Let’s Watch Some Evolution!
Explaining the Evolution
PRINTING TEXT WITH THE FORMAT FUNCTION
Anatomy of the format Function
The Destination Parameter
The Control String Parameter
Value Parameters
Control Sequences for Printing Lisp Values
Control Sequences for Formatting Numbers
Control Sequences for Formatting Integers
Control Sequences for Formatting Floating-Point Numbers
Printing Multiple Lines of Output
Justifying Output
Iterating Through Lists Using Control Sequences
A Crazy Formatting Trick for Creating Pretty Tables of Data
Attack of the Robots!
WORKING WITH STREAMS
Types of Streams
Streams by Type of Resource
Streams by Direction
Working with Files
Working with Sockets
Socket Addresses
Socket Connections
Sending a Message over a Socket
Tidying Up After Ourselves
String Streams: The Oddball Type
Sending Streams to Functions
Working with Long Strings
Reading and Debugging
LET’S CREATE A WEB SERVER!
Error Handling in Common Lisp
Signaling a Condition
Creating Custom Conditions
Intercepting Conditions
Protecting Resources Against Unexpected Conditions
Writing a Web Server from Scratch
How a Web Server Works
Request Parameters
Parsing the Request Header
Testing get-header with a String Stream
Parsing the Request Body
Our Grand Finale: The serve Function!
Building a Dynamic Website
Testing the Request Handler
Launching the Website
What Is Functional Programming?
Anatomy of a Program Written in the Functional Style
Higher-Order Programming
Code Composition with Imperative Code
Using the Functional Style
Higher-Order Programming to the Rescue
Why Functional Programming Is Crazy
Why Functional Programming Is Fantastic
Functional Programming Reduces Bugs
Functional Programs Are More Compact
Functional Code Is More Elegant
The Rules of Dice of Doom
A Sample Game of Dice of Doom
Implementing Dice of Doom, Version 1
Defining Some Global Variables
Representing the Game Board
Decoupling Dice of Doom’s Rules from the Rest of the Game
Generating a Game Tree
Calculating Passing Moves
Calculating Attacking Moves
Finding the Neighbors
Attacking
Reinforcements
Trying Out Our New game-tree Function
Playing Dice of Doom Against Another Human
Creating an Intelligent Computer Opponent
The Minimax Algorithm
Turning Minimax into Actual Code
Creating a Game Loop with an AI Player
Playing Our First Human vs. Computer Game
Making Dice of Doom Faster
Closures
Memoization
Tail Call Optimization
A Sample Game on the 3-by-3 Board
THE MAGIC OF LISP MACROS
A Simple Lisp Macro
Macro Expansion
How Macros Are Transformed
Using the Simple Macro
More Complex Macros
A Macro for Splitting Lists
Avoiding Repeated Execution in Macros
Avoiding Variable Capture
A Recursion Macro
Macros: Dangers and Alternatives
DOMAIN-SPECIFIC LANGUAGES
What Is a Domain?
Writing SVG Files
Creating XML and HTML with the tag Macro
Creating SVG-Specific Macros and Functions
Building a More Complicated SVG Example
Creating Custom Game Commands for Wizard’s Adventure Game
Creating New Game Commands by Hand
Let’s Try the Completed Wizard’s Adventure Game!
LAZY PROGRAMMING
Adding Lazy Evaluation to Lisp
Creating the lazy and force Commands
Creating a Lazy Lists Library
Converting Between Regular Lists and Lazy Lists
Mapping and Searching Across Lazy Lists
Dice of Doom, Version 2
Making Our AI Work on Larger Game Boards
Trimming the Game Tree
Applying Heuristics
Winning by a Lot vs. Winning by a Little
Alpha Beta Pruning
Drawing the Game Board Using the SVG Format
Drawing a Die
Drawing a Tile
Drawing the Board
Building the Web Server Interface
Writing Our Web Request Handler
Limitations of Our Game Web Server
Initializing a New Game
Announcing a Winner
Handling the Human Player
Handling the Computer Player
Drawing the SVG Game Board from Within the HTML
Playing Version 3 of Dice of Doom
MAKING DICE OF DOOM MORE FUN
Increasing the Number of Players
Rolling the Dice
Building Chance Nodes
Doing the Actual Dice Rolling
Calling the Dice Rolling Code from Our Game Engine
Updating the AI
Improving the Dice of Doom Reinforcement Rules
Conclusion
EPILOGUE
INDEX
0 of .
Results for:
No results containing your search query
P. 1
Land of Lisp

Land of Lisp

Ratings: (0)|Views: 121|Likes:

More info:

Published by: Mandeep Singh Dhaliwal on Nov 04, 2011
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

04/15/2013

pdf

text

original

You're Reading a Free Preview
Pages 11 to 105 are not shown in this preview.
You're Reading a Free Preview
Pages 116 to 118 are not shown in this preview.
You're Reading a Free Preview
Pages 129 to 175 are not shown in this preview.
You're Reading a Free Preview
Pages 186 to 482 are not shown in this preview.
You're Reading a Free Preview
Pages 493 to 508 are not shown in this preview.

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->