modding:function:or
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
modding:function:or [2014/12/27 04:40] – external edit 127.0.0.1 | modding:function:or [2017/01/26 00:26] (current) – 0xabcdef | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | [[modding: | + | [[or Talk Page|Discuss this page]] |
=== or === | === or === | ||
- | [[modding:function:or]] | + | See [[http:// |
- | ^ Syntax | (or [condition]^1) | | + | ^ Syntax | (or exp1 [exp2 ... expn]) -> value/ |
- | ^ Arguments | [condition]: Something other than Nil or Nil | | + | ^ Arguments | exp1: An expression that evaluates to **Nil** or something else | |
- | ^ | ^1 | | + | ^ [exp2 ... expn] | Additional expressions to be evaluated |
- | ^ Returns | + | ^ Category |
- | [[modding: | + | ^ Returns |
- | ^ Description | Returns | + | ^ Description | Uses lazy evaluation, which means that it stops after it finds a non-**Nil** value or ends up evaluating every argument if all of them return **Nil** |
=== Example === | === Example === | ||
+ | < | ||
+ | (or 1 2 3 4 5 (setq foo 6)) | ||
+ | </ | ||
+ | Return **1**. Also, foo will not be set to **6**. | ||
+ | |||
+ | < | ||
+ | (or Nil (eq (setq foo " | ||
+ | </ | ||
+ | Returns **" | ||
+ | |||
+ | < | ||
+ | (errblock (error b) | ||
+ | (setq b (or c 0)) | ||
+ | b | ||
+ | ) | ||
+ | </ | ||
+ | If **c** has not been bound anything, then this code will return the error **No binding for symbol [c] ### (or c 0) ###** since errors are not **Nil**. Beware of bad code when using **errBlock**, | ||
- | <code lisp> | ||
- | (setq someCondition True) | ||
- | (or someCondition Nil) | ||
- | )</ | ||
- | This will return a True. | ||
Return to [[: | Return to [[: | ||
modding/function/or.1419655255.txt.gz · Last modified: 2017/01/26 00:12 (external edit)