serick83 Posted August 29, 2011 Share Posted August 29, 2011 (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 August 29, 2011 by serick83 Explain I'm not using AutoCAD LT for this. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 29, 2011 Share Posted August 29, 2011 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) ) Quote Link to comment Share on other sites More sharing options...
Steven Erickson Posted August 29, 2011 Share Posted August 29, 2011 Thanks for the quick reply, Lee. I'll check it out when I get back in a few hours. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted August 29, 2011 Share Posted August 29, 2011 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 ? Quote Link to comment Share on other sites More sharing options...
BlackBox Posted August 29, 2011 Share Posted August 29, 2011 [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? Quote Link to comment Share on other sites More sharing options...
Jeff H Posted August 29, 2011 Share Posted August 29, 2011 Ohhhhhhh woooooooooo woooooooooo. Just use Common Lisp or something else. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted August 29, 2011 Share Posted August 29, 2011 BTW - Jeff, I thought your last avatar pic was awesome, but this new one is hilarious. Quote Link to comment Share on other sites More sharing options...
Jeff H Posted August 29, 2011 Share Posted August 29, 2011 Off Topic It reminds everyday to strive to be the best pimp I can be Quote Link to comment Share on other sites More sharing options...
Steven Erickson Posted August 29, 2011 Share Posted August 29, 2011 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. Quote Link to comment Share on other sites More sharing options...
Steven Erickson Posted August 29, 2011 Share Posted August 29, 2011 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. Quote Link to comment Share on other sites More sharing options...
serick83 Posted August 29, 2011 Author Share Posted August 29, 2011 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) ) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 30, 2011 Share Posted August 30, 2011 You're very welcome, hope it helps with your learning Quote Link to comment Share on other sites More sharing options...
BlackBox Posted August 30, 2011 Share Posted August 30, 2011 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 Quote Link to comment Share on other sites More sharing options...
Steven Erickson Posted August 30, 2011 Share Posted August 30, 2011 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.