Lisp loop function not found

Lisp loop function not found

Anonymous
Not applicable
1,749 Views
3 Replies
Message 1 of 4

Lisp loop function not found

Anonymous
Not applicable

I am trying to make my first loop and for some reason this is not working: 

 


(loop for x from 1 to 10 do
(prompt "ASDASD")
(terpri)
)

 

 

; error: no function definition: LOOP

0 Likes
Accepted solutions (2)
1,750 Views
3 Replies
Replies (3)
Message 2 of 4

devitg
Advisor
Advisor
Accepted solution
(setq count 1)
(While (< count 11)



(prompt (strcat "\n" (itoa count) "   asdas   "))

(setq count (1+ count))

)

;;;1   asdas
;;;2   asdas
;;;3   asdas
;;;4   asdas
;;;5   asdas
;;;6   asdas
;;;7   asdas
;;;8   asdas
;;;9   asdas
;;;10   asdas

 

0 Likes
Message 3 of 4

Kent1Cooper
Consultant
Consultant
Accepted solution

@Anonymous wrote:

....
(loop for x from 1 to 10 do
(prompt "ASDASD")
(terpri)

; error: no function definition: LOOP


The error message says it all -- that's not an AutoLisp function.  In addition to the (while) function already suggested, depending on the circumstances you could also use (repeat).  If you really want the same prompt ten times as your example suggests:

 

(repeat 10

  (prompt "ASDASD")

)

Kent Cooper, AIA
0 Likes
Message 4 of 4

martti.halminen
Collaborator
Collaborator

 

The problem here is that you have been reading something about Common Lisp . The LOOP macro exists there, but not in AutoLISP/Visual Lisp.

 

While reading CL materials will probably teach you a better programming style than the stuff from Autodesk, there are large differences between the languages. Back when there used to be printed documentation, the part about AutoLISP was about 66 pages. A book about CL (CLtL2) has an index of 60 pages, the book is about a thousand pages...

AutoLISP has 6 built-in datatypes, IIRC, CL has 17.

 

So, the low-level list manipulation is the same, but most of the more powerful constructs in CL don't exist in AutoLISP.

 

--