乐筑天下

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

[编程交流] 创建多选se

[复制链接]

15

主题

67

帖子

55

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
80
发表于 2022-7-6 08:37:55 | 显示全部楼层
你试过OR过滤器吗?
因此,它返回OR和(NOT)AND的AND。一、 e.仅当或返回True时为True,但和返回FALSE-否则返回FALSE/Nil。
大多数其他语言都有内置的异或函数/运算符,但通常它们的实现方式都是类似的——只是已经为您完成了。
回复

使用道具 举报

26

主题

1495

帖子

20

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
118
发表于 2022-7-6 08:41:30 | 显示全部楼层
不像你尝试使用正则表达式时那么令人困惑。。。但是是的,你需要你的智慧来理解发生了什么。
回复

使用道具 举报

11

主题

968

帖子

919

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
99
发表于 2022-7-6 08:46:01 | 显示全部楼层
有趣的是,还有三种可能的异或函数变体:
 
  1. 5

 
很好的解释Irne
回复

使用道具 举报

5

主题

1334

帖子

1410

银币

限制会员

铜币
-20
发表于 2022-7-6 08:49:30 | 显示全部楼层
回复

使用道具 举报

26

主题

1495

帖子

20

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
118
发表于 2022-7-6 08:51:34 | 显示全部楼层
 
http://cplus.about.com/od/glossar1/g/xor.htm
 
Basically XOR returns T if 1 and only 1 test of 2 operands returns T
回复

使用道具 举报

26

主题

1495

帖子

20

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
118
发表于 2022-7-6 08:55:29 | 显示全部楼层
 
The AND test is normally used for 2 unique DXF group values,   

[code](-4 ".
回复

使用道具 举报

5

主题

1334

帖子

1410

银币

限制会员

铜币
-20
发表于 2022-7-6 08:58:29 | 显示全部楼层
 
Thanks David... It's very understandable link... M.R.
回复

使用道具 举报

11

主题

968

帖子

919

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
99
发表于 2022-7-6 09:01:39 | 显示全部楼层
The usual difficulty when working with and/or/xor is that most people (or rather most languages including English) doesn't define those words exactly as logical comparison defines them. Usually when people say "OR" what they mean is XOR (or Exclusive Or) - i.e. it's either the one or the other - not both. Logic Comp defines OR as "Any of the operands - even just one, but also more than one".
 
Then you get to the AND ... which also sometimes gets confusing. Since people sometimes misuse the word in conversation - you end up with situations like these. In Logic Comp AND means "All the operands - not just some".
 
The way lisp (and most other programming languages) work on these is the following:
 
AND:
 


  • Check if next operand returns True (or not nil in the case of Lisp).
  • If the test is positive, continue. Else return False/Nil.
  • If there's any more operands repeat from 1, else return True.

OR:


  • Check if next operand returns True (or not nil in the case of Lisp).
  • If the test is positive, return True. Else continue.
  • If there's any more operands, repeat from 1. Else return False/Nil.

NOT: Basically an invert toggle. If the operand (only one - doesn't  work on more) is False/Nil return True. If the operand is True/NotNil  return False/Nil.
 
XOR: This is how most people understand the word OR when spoken - i.e. as in "Either OR".
Though Lisp doesn't have a XOR function, you can make one quite easily. The principle behind it would be to combine OR, NOT & AND. E.g.:
  1. (defun XOR (v1 v2 /) (and (or v1 v2) (not (and v1 v2))))
Thus it returns an AND of an OR & (NOT) AND. I.e. True only if OR returns true, but AND returns FALSE - otherwise return False/Nil.
Most other languages have built-in XOR functions/operators, but usually they'd be implemented similarly - just already done for you.
回复

使用道具 举报

11

主题

968

帖子

919

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
99
发表于 2022-7-6 09:03:43 | 显示全部楼层
Not as confusing as when you try to use Regular Expressions  ... but yes, you need your wits about you to understand what's going on.
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 09:06:51 | 显示全部楼层
Three more variations of a possible XOR function, for fun:
 
  1. (defun XOR ( a b )   (or (and a (not b)) (and b (not a))))(defun XOR ( a b )   (and (or (not a) (not b)) (or a b)))(defun XOR ( a b )   (or (not (or (not a) b)) (not (or a (not b)))))
 
Nice explanation Irne
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-9 21:37 , Processed in 0.923942 second(s), 70 queries .

© 2020-2025 乐筑天下

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