member, memq, memv
member(g_objg_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
|
Element to be searched for in l_list or key to be searched in the association table. |
|
Value Returned
|
The part of l_list or association table beginning with the first match of g_obj. |
|
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
Return to top