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

member, memq, memv

member( 
g_obj 
g_arg 
) 
=> l_sublist / t / nil

Description

Returns the largest sublist of l_list whose first element is g_obj or checks whether the key g_obj exists in the association table. For comparison, member uses the equal function, memq uses the eq function, and memv uses eqv.

memq should only be used when comparing symbols and lists. See eq for restrictions on when eq based comparisons can be used.

It is faster to convert a string to a symbol using concat in conjunction with memq than using member, which performs a comparison using equal which is slower, especially for large lists. These functions return a non-nil value if the first argument matches a member of the list passed in as the second argument.

Arguments

g_obj

Element to be searched for in l_list or key to be searched in the association table.

g_arg

A list or an association table.

Value Returned

l_sublist

The part of l_list or association table beginning with the first match of g_obj.

t

The key g_obj exists in the association table.

nil

The key g_obj does not exist in the association table.

Examples

x = "c"                          
=> "c"
member( x '("a" "b" "c" "d"))    
=> ("c" "d")
memq('c '(a b c d c d))          
=> (c d c d)
memq( concat( x ) '(a b c d ))   
=> (c d)
memv( 1.5 '(a 1.0 1.5 "1.5"))    
=> (1.5 "1.5")
tb = makeTable("myTable")
tb[0]= 1
tb["skill"] = 2
member("skill" tb)
=> t

Related Topics

Logical and Relational Functions

eq

equal

eqv

concat


Return to top
 ⠀
X