Author Topic: What's wrong with this Lisp?  (Read 1751 times)

0 Members and 1 Guest are viewing this topic.

vinnyg

  • Guest
What's wrong with this Lisp?
« on: August 31, 2005, 01:40:25 PM »
Hi people,

What's wrong with this lisp? I found it on-line and it doesn't
seem to work.

Vinny

;function to find the midpoint between two points
(defun mid (a b)
(list (/ (+ (car a)(car b)) 2)
(/ (+ (cadr a)(cadr b)) 2)
)
)
 
;function to generate random number
(defun rand (pt / rns rleng lastrn)
(setq rns (rtos (* (car pt)(cadr pt)(getvar "tdusrtimer"))))
(setq rnleng (strlen rns))
(setq lastrn (substr rns rnleng 1))
(setq rn (* 0.6 (atof lastrn)))
(fix rn)
)
 
;The Chaos game
(defun C:CHAOS (/ pta ptb ptc rn count lastpt randn key)
(setq pta '( 2.0000 1 )) ;define point a
(setq ptb '( 7.1962 10)) ;define point b
(setq ptc '(12.3923 1 )) ;define point c
(setq lastpt (getpoint "Pick a start point:")) ;pick a point to start
    (while (/= key 3) ;while pick button not pushed
        (setq randn (rand lastpt)) ;get random number
            (cond ;find midpoint to a b or c
               ( (= randn 0)(setq lastpt (mid lastpt pta)) ) ;use corner a if 0
               ( (= randn 1)(setq lastpt (mid lastpt pta)) ) ;use corner a if 1
               ( (= randn 2)(setq lastpt (mid lastpt ptb)) ) ;use corner b if 2
               ( (= randn 3)(setq lastpt (mid lastpt ptb)) ) ;use corner b if 3
               ( (= randn 4)(setq lastpt (mid lastpt ptc)) ) ;use corner c if 4
               ( (= randn 5)(setq lastpt (mid lastpt ptc)) ) ;use corner c if 5
            );end cond
        (grdraw lastpt lastpt 5) ;draw midpoint
        (setq key (car (grread T))) ;test for pick
     );end while
);end Chaos

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
What's wrong with this Lisp?
« Reply #1 on: August 31, 2005, 01:44:13 PM »
That's because it's a game => it's not designed to do work.

:)
Engineering Technologist CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.com http://cadanalyst.slack.com http://linkedin.com/in/cadanalyst

JohnK

  • Administrator
  • Seagull
  • Posts: 10550
What's wrong with this Lisp?
« Reply #2 on: August 31, 2005, 01:49:56 PM »
I dont understand the game. *lol*
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org