Elisp List Contains a Value

前端 未结 2 1059
情书的邮戳
情书的邮戳 2021-02-01 02:22

How do you check, in elisp, if a list contains a value? so the following would return t:

(contains 3 \'(1 2 3))

but

(contains          


        
2条回答
  •  余生分开走
    2021-02-01 02:45

    The function you need is member

    For example:

    (member 3 '(1 2 3))
    

    It will return the tail of list whose car is element. While this is not strictly t, any non-nil value is equivalent to true for a boolean operation. Also, member uses equal to test for equality, use memq for stricter equality (using eq).

提交回复
热议问题