User Tools

Site Tools


modding:function:and

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
modding:function:and [2014/12/27 04:40] – external edit 127.0.0.1modding:function:and [2017/01/27 02:17] (current) 0xabcdef
Line 1: Line 1:
-[[modding:function:and]]+[[and Talk Page | Discuss this page]]
  
 === and === === and ===
  
-[[modding:function:and]]+See [[http://xelerus.de/index.php?s=functions&function=3 | and on Xelerus]]
  
-^ 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: the result of anding all of the expressions +^ 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 functions | logical operator]] | 
-^ Description | Returns True if all the expressions are not Nil otherwise returns Nil. |+^ 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 ===
  
-<code lisp>(block (someCondition)  +<code> 
- (setq someCondition True+(and Nil (setq foo 100)
- (and someCondition Nil) +</code> 
- )</code> +Returns **Nil**. Also, **foo** will not be set to 100 
-This will return a Nil.+ 
 +<code> 
 +(and (setq foo 200) Nil (setq bar "baz")) 
 +</code> 
 +Returns **Nil**. Also, **foo** will be set to **200** and **bar** will not be set to **"baz"** 
 + 
 +<code> 
 +(and (gr (count (setq foo (list Nil Nil Nil))) 2) 5) 
 +</code> 
 +Returns **5**. Also, **foo** will be set to **(Nil Nil Nil)** 
 + 
 +<code> 
 +(and (setq foo Nil) (setq bar True)) 
 +</code> 
 +Returns **Nil**Also, **foo** will be set to **Nil** and **bar** will not be set to **True** 
 Return to [[:Functions]] list Return to [[:Functions]] list
  
modding/function/and.1419655255.txt.gz · Last modified: 2017/01/26 00:34 (external edit)