Elisp List Contains a Value

前端 未结 2 1058
情书的邮戳
情书的邮戳 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:33

    freiksenet's answer is good and idiomatic. If you are using dash.el, you could also call function -contains?, which does exactly the same—checks if some list contains an element:

    (-contains? '(1 2 3) 2) ; t
    

提交回复
热议问题