Jump to content

Not AutoCAD related, but LISP related...


Recommended Posts

Posted (edited)

This was something I worked on last year, but shelved it until now. With college football quickly approaching I'd decided to give it another try. Because LISP works well with lists, it seems natural to apply it to football pools. It represents one person's predicted scores and compares it with the actual scores, then prints the person's name and point differential compared to actual scores for two games. (eg. Bill91 34pts).

 

I'm getting a bad argument error for some reason.

 

[EDIT: I have AutoCAD LT2007, but am using AutoCAD clone for this.]

 

(defun ptdiff ()

  (setq actscr '(24 21 24 27))
  (setq urscr '(("Bill91" 10 31 20 21)
                     ("dante" 21 30 24 20)
                     ("91dwg" 10 31 21 28)   
                   )
  )

(while
  (setq urscr (car urscr))
  (princ (car urscr))

  (setq gm1 (+ (abs (- (nth 1 urscr)(nth 0 actscr)))(abs (- (nth 2 urscr)(nth 1 actscr))))
        gm2 (+ (abs (- (nth 3 urscr)(nth 2 actscr)))(abs (- (nth 4 urscr)(nth 3 actscr))))
  )
  (setq sum (+ gm1 gm2))
  (princ " ")
  (princ sum) 
  (princ "pts")

  (setq urscr (cdr urscr))
) 
  (princ)
)

Edited by serick83
Explain I'm not using AutoCAD LT for this.
Posted

Perhaps:

 

(defun ptdiff ( / actscr item urscr )

   (setq actscr '(24 21 24 27))

   (setq urscr
      '(
           ("Bill91" 10 31 20 21)
           ("dante" 21 30 24 20)
           ("91dwg" 10 31 21 28)   
       )
   )

   (while (setq item (car urscr))
       (princ
           (strcat "\n" (car item) " "
               (itoa (apply '+ (mapcar 'abs (mapcar '- (cdr item) actscr)))) "pts"
           )
       )
       (setq urscr (cdr urscr))
   )
   (princ)
)

 

Your error was caused by:

 

(while (setq urscr (car urscr))  ==>  urscr = [font=monospace]([/font]"Bill91" 10 31 20 21)

 (setq urscr (cdr urscr))  ==>  urscr = (10 31 20 21)
)

Posted

Thanks for the quick reply, Lee. I'll check it out when I get back in a few hours.

Posted
Thanks for the quick reply, Lee. I'll check it out when I get back in a few hours.

 

Are you the the same OP ? :D

Posted

[EDIT: I have AutoCAD LT2007, but am using AutoCAD clone for this.]

 

Thanks for the quick reply, Lee. I'll check it out when I get back in a few hours.

 

Please clarify... Am I correct in understanding that you have two CADTutor accounts (serick83, and Steven Erickson), and that you are using 'clone' (i.e., non-authorized) software to make AutoCAD 2007 LT *think*, or *act* like a full version of AutoCAD? :unsure:

Posted

Ohhhhhhh woooooooooo woooooooooo.

 

Just use Common Lisp or something else.

Posted

:offtopic:

 

BTW - Jeff, I thought your last avatar pic was awesome, but this new one is hilarious. :thumbsup:

Posted

Off Topic

 

It reminds everyday to strive to be the best pimp I can be

Posted

Tharwat:

 

Yes. I don't know what happened. I was signed in with the first username, but when I went to quickly send out a response to Lee Mac it somehow changed to my previous username. Sorry for the confusion.

Posted

Renderman:

 

As I mentioned to Tharwat I was signed in with the first username, but when I responded to Lee Mac it somehow converted to my previous username.

 

No, I'm not using something non-authorized. Because my LT doesn't have the ability to use AutoLISP I'm using a AutoCAD competitor on a 30-day trial. Sorry about not making myself clear.

Posted

Wow. It works great. Thanks for cleaning up the code and making in more efficient.

 

[EDIT: I realize why my username was different. I was using two different computers with different usernames]

 

Perhaps:

 

(while (setq item (car urscr))
       (princ
           (strcat "\n" (car item) " "
               (itoa (apply '+ (mapcar 'abs (mapcar '- (cdr item) actscr)))) "pts"
           )
       )
       (setq urscr (cdr urscr))
   )
   (princ)
)

Posted

No, I'm not using something non-authorized. Because my LT doesn't have the ability to use AutoLISP I'm using a AutoCAD competitor on a 30-day trial. Sorry about not making myself clear.

 

No worries; I appreciate the clarification. :)

 

[EDIT: I realize why my username was different. I was using two different computers with different usernames]

 

Like I said before... two different member accounts. I'm pretty sure the limit is (meant to be) one per user. Contact an Admin - they can help you merge the two accounts (i.e., your posts, etc.).

 

HTH

Posted
No worries; I appreciate the clarification. :)

 

Like I said before... two different member accounts. I'm pretty sure the limit is (meant to be) one per user. Contact an Admin - they can help you merge the two accounts (i.e., your posts, etc.).

 

HTH

 

 

I'll go ahead and do that. Thanks.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...