Michaels 发表于 2022-7-6 09:34:04

Check number in a list (singul

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

pBe 发表于 2022-7-6 09:38:59

 
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)

Michaels 发表于 2022-7-6 09:41:07

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 .

pBe 发表于 2022-7-6 09:44:14

so i see...
 
(post updated).. you are pertaining to ODD/EVEN?

Michaels 发表于 2022-7-6 09:47:27

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

MSasu 发表于 2022-7-6 09:50:46

This is an issue that was discussed few hours ago - did you checked the link that pBe suggested?
 
Regards,
Mircea

Michaels 发表于 2022-7-6 09:55:46

 
I have seen that link before, and it does not meet my needs .
 
Many thanks .

pBe 发表于 2022-7-6 09:58:59

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"));

Michaels 发表于 2022-7-6 09:59:42

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 ?

MSasu 发表于 2022-7-6 10:04:09

If you don't mean odd by "singular", respectively even by "plural", you should provide more information regarding your request. Thank you.
 
Regards,
Mircea
页: [1] 2
查看完整版本: Check number in a list (singul