Question

running a lisp program in Allegro CL

Asked by: yourikh

Hi all,

I'm new to the Lisp world. I'm using Allegro CL as my IDE. I have a program (2d.lisp) that I would like to run under this environment but I get an error every time I try to run this code.  All I do is to type in (load "2d.lisp") to load the file. Then when I try to run the function by typing in (path-planning-problem (*scene-4.17*)) I get an error. I have attached the 2d.lisp to this post.

I'm not sure what I'm doing wrong  and I'd appreciate your help.

;;; path-planning.lisp
;;; Definitions for the problem of finding optimal paths in two dimensions
;;; with convex polygonal obstcles. The scene is specified with the
;;; visible vertices precalculated for each vertex.
 
(defstruct (vertex (:print-function print-vertex))
  xy           ;; the xy point for the vertex
  c-neighbor   ;; neighbour in clockwise direction
  a-neighbor   ;; neighbour in anti-clockwise direction
  visible      ;; list of vertices visible from here
  )
 
(defun print-vertex (v &optional (stream t) depth)
  (declare (ignore depth))
  (format stream "VERTEX~A" (vertex-xy v)))
 
(defstruct line
  xy1 xy2)
 
(defstruct polygon
  entry-vertex vertices n)
 
(defstruct scene
  polygons				; polygons comprising scene
  start-polygon				; polygon for start 
  goal-polygon				; polygon for goal
  )
 
;;;; Creating a Path Planning Problem
 
 
(defun path-planning-problem (scene)
  "Create a path-planning problem from a description of a scene."
  ;; States are represented by a single vertex.
  (let ((start (polygon-entry-vertex (scene-start-polygon scene)))
	(goal  (polygon-entry-vertex (scene-goal-polygon scene))))
    (make-problem
     :initial-state      start
     :successor-fn       #'(lambda (v1) (path-planning-successors v1 scene))
     :goal-test          #'(lambda (v1) (eq v1 goal))
     :g-cost-fn          nil
     :h-cost-fn          #'(lambda (v1) 
			     (xy-distance (vertex-xy v1) (vertex-xy goal)))
     :edge-cost-fn       #'(lambda (v1 v2) 
			     (xy-distance (vertex-xy v1) (vertex-xy v2)))
     :hash-key           #'vertex-xy
     :domain             "path-planning"
     )))
 
 
(defun path-planning-successors (v1 scene)
  "Return a list of (action . state) pairs, where the state is another
  vertex that is visible from here, and the action is a delta (dx dy)
  from the current vertex to the new one."
  (let ((p1 (vertex-xy v1)))
    (mapcar #'(lambda (v2) (let ((p2 (vertex-xy v2)))
			     (cons (make-xy :x (- (xy-x p2) (xy-x p1)) 
					    :y (- (xy-y p2) (xy-y p1)))
				   v2)))
	    (vertices-visible-from v1 scene))))
 
 
;;; Functions for testing whether one vertex is visible from another
 
(defun vertices-visible-from (v1 scene)
  "Find all the vertices that can be seen from this vertex."
  ;; When you find them, cache them under the vertex-visible slot.
  (or (vertex-visible v1)
      (setf (vertex-visible v1) (vertices-in-view v1 scene))))
	    
(defun vertices-in-view (v scene)
  "Find all the other vertices that can be seen from v."
  (delete v
   (with-collection ()
    (for each poly in (scene-polygons scene) do
	 (cond ((member v (polygon-vertices poly))
		(collect (vertex-c-neighbor v))
		(collect (vertex-a-neighbor v)))
	       (t (for each v2 in (polygon-vertices poly) do
		       (when (visible-p (vertex-xy v) (vertex-xy v2) scene)
			 (collect v2)))))))))
 
(defun visible-p (xy1 xy2 scene)
  "Predicate; return t iff xy1 is visible from xy2."
  (let ( (line (make-line :xy1 xy1 :xy2 xy2)) )
    (dolist (poly (scene-polygons scene) t)
      (if (line-intersects-poly? line poly) (return nil)))))
 
(defun line-intersects-poly? (line poly)
  "Predicate; return t iff line intersects poly."
  (dolist (v1 (polygon-vertices poly) nil)
    (let ((v2 (vertex-c-neighbor v1)))
      (if (intersects line 
                      (make-line :xy1 (vertex-xy v1) :xy2 (vertex-xy v2)))
	  (return t)))))
 
(defun intersects (l1 l2)   
;;; l1 is line ab; l2 is line cd
;;; assume the lines cross at alpha a + (1-alpha) b, 
;;;     also known as beta c + (1-beta) d
;;; line segments intersect if 0<alpha,beta<1 unless they're parallel
  (let* ((a (line-xy1 l1))
	 (b (line-xy2 l1))
	 (c (line-xy1 l2))
	 (d (line-xy2 l2))
	 (xa (xy-x a)) (ya (xy-y a))
	 (xb (xy-x b)) (yb (xy-y b))
	 (xc (xy-x c)) (yc (xy-y c))
	 (xd (xy-x d)) (yd (xy-y d))
	 (q (- (* (- xa xb) (- yc yd))
	       (* (- ya yb) (- xc xd)))))
    (unless (zerop q)
      (let ((alpha (/ (- (* (- xd xb) (- yc yd))
			 (* (- yd yb) (- xc xd)))
		      q))
	     (beta (/ (- (* (- xd xb) (- ya yb))
			   (* (- yd yb) (- xa xb)))
		         q)))
	(and (< 0 alpha 1) (< 0 beta 1))))))
 
 
;;;; Code for constructing the scene data structure
 
(defun create-scene (start goal polygon-data)
  (let ((scene
	 (make-scene
	  :start-polygon (create-polygon (list start))
	  :goal-polygon  (create-polygon (list goal)))))
    (setf (scene-polygons scene)
	  (cons (scene-start-polygon scene)
		(cons (scene-goal-polygon scene)
		      (mapcar #'create-polygon polygon-data))))
    scene))
 
(defun create-polygon (points)
  ;; Assumes that points are given in anticlockwise order (or in order, anyway)
  (let* ((vertices (mapcar #'(lambda (xy) (make-vertex :xy xy)) points))
	 (poly (make-polygon :vertices vertices)))
    (setf (polygon-entry-vertex poly) (first vertices))
    (setf (polygon-n poly) (length vertices))
    (dolist (v vertices)
      (let ((v2 (or (cadr (member v vertices :test #'eq))
		    (first vertices))))
	(setf (vertex-a-neighbor v) v2)
	(setf (vertex-c-neighbor v2) v)))
    poly))      
    
;;;; Specific scene, shown as Figure 4.17 [p 120]
 
(defparameter *scene-4.17*
  (create-scene 
   '(112 660) ;;start
   '(353 573) ;;goal
   ;; each polygon is represented as a list of (x y) coordinates of vertices
   '(((220 616) (220 666) (251 670) (272 647))
     ((341 655) (359 667) (374 651) (366 577))
     ((311 530) (311 559) (339 578) (361 560) (361 528) (336 516))
     ((105 628) (151 670) (180 629) (156 577) (113 587))
     ((118 517) (245 517) (245 557) (118 557))
     ((280 583) (333 583) (333 665) (280 665))
     ((252 594) (290 562) (264 538))
     ((198 635) (217 574) (182 574))
     ))
  "The scene in Figure 4.17 [p 120] with 8 obstacles.")

                                  
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:

Select allOpen in new window

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2008-10-20 at 00:19:24ID23828775
Tags

lisp

Topics

LISP

,

Programming Languages

Participating Experts
0
Points
0
Comments
1

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. CLS for C++
    I was wondering, is there a CLS (clearscreen places cursor at the top left) command for C++? fred (real name)
  2. AS400 CL programming
    Is it possible to write to a database physical file within a CL program, using data created through a variable e.g. current date value. I wish to write the &MSGDTA variable to a file for future processing. PGM ...
  3. Submit a batch job in one CL pgm
    I want to call a pgm in batch mode using one CL pgm only, by combining the batch call with the final pgm call. I am passing parms and can do so with a DS or by passing the parms themselves. The programmer before me would always have one CL interact with the screen, call the...
  4. Not CLS-Compliant Exception
    I just started using Crystal Reports 10 with .NET 2.0, after using my reports with ASP for years. It is a new world for me, and I am lost. I get this error over and over: Return type of function 'ReportHeaderSection1' is not CLS-compliant 1) What would be causing this?...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: yourikhPosted on 2008-10-20 at 01:43:12ID: 22755862

pls close the question

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...