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

existss

existss( 
s_formalVar 
l_valueList 
g_predicateExpr 
)
=> g_result
existss( 
s_key 
o_table 
g_predicateExpr 
)
=> t / nil

Description

Returns the first tail of l_valueList whose car satisfies a predicate expression. Also verifies whether an entry in an association table satisfies a predicate expression. In the SKILL++ mode, this function always locally wraps the loop or iterator local variable (s_formalVar) in a let block while compiling the code. Local wrapping preserves the lexical scope of the loop variable. This function may work slower than its non-wrapped counterpart exists. This is a syntax form.

This process continues to apply the cdr function successively through l_valueList until it finds a list element that causes g_predicateExpr to evaluate to non-nil. It then returns the tail that contains that list element as its first element.

This function can also be used to verify whether an entry in an association table satisfies g_predicateExpr.

Arguments

s_formalVar

Local variable that is usually referenced in g_predicateExpr.

l_valueList

List of elements that are bound to s_formalVar, one at a time.

g_predicateExpr

SKILL expression that usually uses the value of s_formalVar.

s_key

Key portion of an association table entry.

o_table

Association table containing the entries to be processed.

Value Returned

g_result

First tail of l_valueList whose car satisfies g_predicateExpr.

nil

If none of the elements in l_valueList can satisfy it.

t

Entry in an association table satisfies g_predicateExpr.

Examples

(defun test_exists (x)
    existss( x (list x x+1 x+9) println(x))
    println(x)
    )
test_exists(9)

=> 9
10
18
9
nil

Also, see the example for the foreachs function.

Related Topics

Flow Control Functions

car

cdr

exists


Return to top
 ⠀
X