modding:function:and
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
modding:function:and [2014/12/27 04:40] – external edit 127.0.0.1 | modding:function:and [2017/01/27 02:17] (current) – 0xabcdef | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | [[modding: | + | [[and Talk Page | Discuss this page]] |
=== and === | === and === | ||
- | [[modding:function:and]] | + | See [[http:// |
- | ^ Syntax | (and exp1 exp2 ... expn) -> True/Nil | | + | ^ Syntax | (and exp1 [exp2 ... expn]) -> value/Nil | |
- | ^ Arguments | exp1: an expression that evaluates to Nil or non-Nil | | + | ^ Arguments | exp1: an expression that evaluates to **Nil** or non-**Nil** | |
- | ^ | exp2 ... expn: optional expressions that each evaluate to Nil or non-Nil. | | + | ^ | [exp2 ... expn]: optional expressions that each evaluate to **Nil** or non-**Nil**. | |
- | ^ Returns | boolean: | + | ^ Returns | If all arguments return a non-**Nil** value, then returns |
- | ^ Category | [[logical operator]] | | + | ^ Category | [[logical operator functions | logical operator]] | |
- | ^ Description | Returns True if all the expressions are not Nil otherwise returns | + | ^ Description | Uses lazy evaluation, which means that it stops after it finds a **Nil** value or ends up evaluating every argument |
=== Example === | === Example === | ||
- | < | + | < |
- | (setq | + | (and Nil (setq foo 100)) |
- | (and someCondition | + | </ |
- | )</ | + | Returns **Nil**. Also, **foo** will not be set to 100 |
- | This will return a Nil. | + | |
+ | < | ||
+ | (and (setq foo 200) Nil (setq bar " | ||
+ | </ | ||
+ | Returns **Nil**. Also, **foo** will be set to **200** and **bar** will not be set to **" | ||
+ | |||
+ | < | ||
+ | (and (gr (count (setq foo (list Nil Nil Nil))) 2) 5) | ||
+ | </ | ||
+ | Returns **5**. Also, **foo** | ||
+ | |||
+ | < | ||
+ | (and (setq foo Nil) (setq bar True)) | ||
+ | </ | ||
+ | Returns **Nil**. Also, **foo** will be set to **Nil** and **bar** will not be set to **True** | ||
Return to [[: | Return to [[: | ||
modding/function/and.1419655255.txt.gz · Last modified: 2017/01/26 00:34 (external edit)