User Tools

Site Tools


modding:function:and

Discuss this page

and

See and on Xelerus

Syntax (and exp1 [exp2 … expn]) → value/Nil
Arguments exp1: an expression that evaluates 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. If there is only one argument, then returns the value of that argument.
Category 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.

Example

(and Nil (setq foo 100))

Returns Nil. Also, foo will not be set to 100

(and (setq foo 200) Nil (setq bar "baz"))

Returns Nil. Also, foo will be set to 200 and bar will not be set to “baz”

(and (gr (count (setq foo (list Nil Nil Nil))) 2) 5)

Returns 5. Also, foo will be set to (Nil Nil Nil)

(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 Functions list

modding/function/and.txt · Last modified: 2017/01/27 02:17 by 0xabcdef