serick83 发表于 2022-7-6 08:59:06

Not AutoCAD related, but LISP

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.
 

 

(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))

Lee Mac 发表于 2022-7-6 09:07:12

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 = ("Bill91" 10 31 20 21) (setq urscr (cdr urscr))==>urscr = (10 31 20 21))

Steven Erickson 发表于 2022-7-6 09:09:35

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

Tharwat 发表于 2022-7-6 09:16:20

 
Are you the the same OP ?

BlackBox 发表于 2022-7-6 09:19:37

 
 
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?

Jeff H 发表于 2022-7-6 09:24:06

Ohhhhhhh woooooooooo woooooooooo.
 
Just use Common Lisp or something else.

BlackBox 发表于 2022-7-6 09:27:03

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

Jeff H 发表于 2022-7-6 09:33:01

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

Steven Erickson 发表于 2022-7-6 09:36:34

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.

Steven Erickson 发表于 2022-7-6 09:41:00

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.
页: [1] 2
查看完整版本: Not AutoCAD related, but LISP