modding:function:and
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
modding:function:and [2017/01/26 00:34] – 0xabcdef | modding:function:and [2017/01/27 02:17] – 0xabcdef | ||
---|---|---|---|
Line 8: | Line 8: | ||
^ 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 | If all arguments return a non-**Nil** value, then returns the value of the last argument. Otherwise, returns **Nil** | | + | ^ Returns | If all arguments return a non-**Nil** value, then returns the value of the last argument. Otherwise, returns **Nil**. If there is only one argument, then returns the value of that argument. |
- | ^ Category | [[logical operator]] | | + | ^ Category | [[logical operator function | logical operator]] | |
- | ^ Description | Uses lazy evaluation, which means that it stops after it finds a **Nil** value or ends up evaluating every argument if all of them return a non-**Nil** value | | + | ^ Description | Uses lazy evaluation, which means that it stops after it finds a **Nil** value or ends up evaluating every argument if all of them return a non-**Nil** value. | |
=== Example === | === Example === | ||
Line 27: | Line 27: | ||
(and (gr (count (setq foo (list Nil Nil Nil))) 2) 5) | (and (gr (count (setq foo (list Nil Nil Nil))) 2) 5) | ||
</ | </ | ||
- | Returns **5**. Also, **foo** will be set to **300** | + | Returns **5**. Also, **foo** will be set to **(Nil Nil Nil)** |
< | < | ||
(and (setq foo Nil) (setq bar True)) | (and (setq foo Nil) (setq bar True)) | ||
</ | </ | ||
- | Returns **Nil**. Also, **foo** will be set to **Nil** and **bar** will not be set to **" | + | Returns **Nil**. Also, **foo** will be set to **Nil** and **bar** will not be set to **True** |
Return to [[: | Return to [[: | ||
modding/function/and.txt · Last modified: 2017/01/27 02:17 by 0xabcdef