Product Documentation
Cadence SKILL Language Reference
Product Version IC23.1, November 2023

caseq

caseq( 
g_keyForm 
l_clause1 
[ l_clause2 ... ] 
) 
=> g_result / nil

Description

Works like the case() function, but uses eq() to find a matching clause instead of the equal() function. The keys used with caseq() should therefore not be strings or lists. In case you want to use a string value or a list, SKILL recommends using the case() function. See eq for details on the difference between the eq() and equal() functions.

Arguments

g_keyForm

An expression whose value is evaluated and tested for equality against the comparators in each clause. A match occurs when either the selector is equal to the comparator or the selector is equal to one of the elements in the list given as the comparator.

If a match is found, the expressions in that clause and that clause only (that is, the first match) are executed. The value of case is then the value of the last expression evaluated (that is, the last expression in the clause selected).

If there is no match, case returns nil.

l_clause1

An expression whose first element is an atom or list of atoms to be compared against the value of g_keyForm. The remainder of the l_clause is evaluated if a match is found.

l_clause2

Zero or more clauses of the same form as l_clause1.

Value Returned

g_result

The value of the last expression evaluated in the matched clause, or nil if there is no match.

nil

If there is no match.

Examples

caseq(value
((nil) printf("Failed.\n"))
(indeterminate printf("Indeterminate.\n"))
((t) printf("Succeeded.\n"))
(t printf("Default.\n"))
)) 

Related Topics

Flow Control Functions


Return to top
 ⠀
X