Michaels Posted April 27, 2011 Posted April 27, 2011 Hello . How could I check the return number in a list ( singular or plural) ? (setq Nums '(1 2 3 4 5 6)) (setq List1 (nth 0 Nums)) Thanks Quote
pBe Posted April 27, 2011 Posted April 27, 2011 (edited) Hello . How could I check the return number in a list ( singular or plural) ? Thanks has this been asked before ? use REM http://www.cadtutor.net/forum/showthread.php?58679-how-CAD-knows-a-number-is-singular-or-plural You can though parse the list to remove Odd/Even (defun OddEven (OE lst) (setq New_list (vl-remove-if-not '(lambda (i) (= (rem i 2) oe)) lst)) ) 1 for odd 0 for even (oddeven 1 nums) (1 3 5) (oddeven 0 nums) (2 4 6) Edited April 27, 2011 by pBe Quote
Michaels Posted April 27, 2011 Author Posted April 27, 2011 Thank you pBe . But that's not what I meant buddy . I mean how to know if the return number is singular or plural ? 1 is singular . but how to check by lisp ? 4 is plural . how to get sure of that ? Many thanks . Quote
pBe Posted April 27, 2011 Posted April 27, 2011 so i see... (post updated).. you are pertaining to ODD/EVEN? Quote
Michaels Posted April 27, 2011 Author Posted April 27, 2011 The return of your sub-routine would give numbers in a list which is not what I looking for . I would like to get sure if a number is singular which is hold by argument . Thanks Quote
MSasu Posted April 27, 2011 Posted April 27, 2011 This is an issue that was discussed few hours ago - did you checked the link that pBe suggested? Regards, Mircea Quote
Michaels Posted April 27, 2011 Author Posted April 27, 2011 This is an issue that was discussed few hours ago - did you checked the link that pBe suggested? Regards, Mircea I have seen that link before, and it does not meet my needs . Many thanks . Quote
pBe Posted April 27, 2011 Posted April 27, 2011 of course it does.. like this (defun c:Test () (setq Nums '(1 2 3 4 5 6)) (foreach n nums (if (= (rem n 2) 1) (print (strcat (itoa n )" is Odd"));<--put your code here if its Odd (print (strcat (itoa n) " is Even"));<--put your code here if its Even ) ) (princ) ) You need to supply the argument yourself as we dont know what exactly you want done with the result Quote
Michaels Posted April 27, 2011 Author Posted April 27, 2011 Am I still not clear . (setq num (getint "\n Number :")) ;;; Enter 3 so now the argument (num) is equal to 3 . so how to know the number which is held by the argument is singular or plural ? Quote
MSasu Posted April 27, 2011 Posted April 27, 2011 If you don't mean odd by "singular", respectively even by "plural", you should provide more information regarding your request. Thank you. Regards, Mircea Quote
Tiger Posted April 27, 2011 Posted April 27, 2011 singular = 1 Plural = every number but 1 perhaps? Quote
dbroada Posted April 27, 2011 Posted April 27, 2011 singular = 1Plural = every number but 1 perhaps? I'm glad I'm not the only one who reads it that way. Quote
pBe Posted April 27, 2011 Posted April 27, 2011 Am I still not clear . (setq num (getint "\n Number :")) ;;; Enter 3 so now the argument (num) is equal to 3 . so how to know the number which is held by the argument is singular or plural ? (defun c:test () (setq num (getint "\n Number: ")) (if (= (rem num 2) 1) (princ "\nYou Entered Odd number:") (princ "\nYou Entered Even number:") )(princ) ) ?????????? (defun c:test () (setq num (getint "\n Number: ")) (if (> num 1) (princ "\nYou Entered a higher number than 1") (princ "\nYou Entered Number 1") )(princ) ) ?????????? (defun c:test () (setq num (getint "\n Number: ")) (if (< num 9) (princ "\nYou Entered Singular") (princ "\nYou Entered Plural") )(princ) ) ??????????? Enough!! Enough!!! Quote
Michaels Posted April 27, 2011 Author Posted April 27, 2011 Fantastic pBe . That's it . Appreciated a lot buddy. Quote
pBe Posted April 27, 2011 Posted April 27, 2011 Fantastic pBe . That's it . Appreciated a lot buddy. for which one? Quote
Michaels Posted April 27, 2011 Author Posted April 27, 2011 for which one? All of them are perfect buddy . Quote
dbroada Posted April 27, 2011 Posted April 27, 2011 and we are none the wiser to what a plural number is Quote
Michaels Posted April 27, 2011 Author Posted April 27, 2011 and we are none the wiser to what a plural number is I am sorry , I should have written "even" instead of "plural" which made the confusion . I appologize . Quote
Lee Mac Posted April 27, 2011 Posted April 27, 2011 Perhaps see this thread: http://www.cadtutor.net/forum/showthread.php?58679-how-CAD-knows-a-number-is-singular-or-plural Quote
pBe Posted April 27, 2011 Posted April 27, 2011 I am sorry , I should have written "even" instead of "plural" which made the confusion . I appologize . No worries.. we had fun Quote
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.