Structural Informatics Group (SIG) logo
Home | Projects | Demos | Downloads | Publications | Local Info | About Us | New site
Go to the first, previous, next, last section, table of contents.

if

source files: [cx]lsp.[ch]

SYNTAX

(if <conditional-expression> <then-expression> <else-expression> ...)

DESCRIPTION

This operator evaluates <conditional-expression>. If this is nonzero, <then-expression> is evaluated and returned, otherwise the <else-expression>s are evaluated and the result of the last one returned.

Since this is a vector interpreter, this isn't done quite as you might expect at first: <conditional-expression> is used as a bitmask to control evaluation of the other expressions on an element-by-element basis, the <conditional-expression> being bitwise-inverted before being used to control the <else-expression>s. This is mentioned just to re-assure the application programmer that no great efficiency penalty is suffered by using the IF operator ... at worst perhaps a 30% slowdown on particularly fast operations.

See also the UNLESS and WHEN operators.


Go to the first, previous, next, last section, table of contents.