乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 97|回复: 19

[编程交流] Check number in a list (singul

[复制链接]

55

主题

293

帖子

239

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
275
发表于 2022-7-6 09:34:04 | 显示全部楼层 |阅读模式
Hello .
 
How could I check the return number in a list ( singular or plural)  ?
 
  1. (setq Nums '(1 2 3 4 5 6))(setq List1 (nth 0 Nums))
 
Thanks
回复

使用道具 举报

pBe

32

主题

2722

帖子

2666

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
211
发表于 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
 
  1. (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)
回复

使用道具 举报

55

主题

293

帖子

239

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
275
发表于 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

32

主题

2722

帖子

2666

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
211
发表于 2022-7-6 09:44:14 | 显示全部楼层
so i see...
 
(post updated).. you are pertaining to ODD/EVEN?
回复

使用道具 举报

55

主题

293

帖子

239

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
275
发表于 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
回复

使用道具 举报

35

主题

2471

帖子

2447

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
174
发表于 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
回复

使用道具 举报

55

主题

293

帖子

239

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
275
发表于 2022-7-6 09:55:46 | 显示全部楼层
 
I have seen that link before, and it does not meet my needs .
 
Many thanks .
回复

使用道具 举报

pBe

32

主题

2722

帖子

2666

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
211
发表于 2022-7-6 09:58:59 | 显示全部楼层
of course it does..
 
like this

[code] (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"));
回复

使用道具 举报

55

主题

293

帖子

239

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
275
发表于 2022-7-6 09:59:42 | 显示全部楼层
Am I still not clear .
 
  1. (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 ?
回复

使用道具 举报

35

主题

2471

帖子

2447

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
174
发表于 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
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-7-4 14:31 , Processed in 0.758004 second(s), 73 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表