This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.

How to find the position of atom in the list

2 posts · 1363 views

How to find the position of an atom in the list. for eg

(position-in-list 'a (a b c d e))
-> 0

(position-in-list 'b (a b c d e) )
-> 1

(position-in-list 'Z(a b c d e) )
->nil.

Re: How to find the position of atom in the list

I replied in your previous thread with a working position-in-list function. However, Common Lisp provides a standard position function which will meet your needs. In you case, you can call it by:
(position 'a '(a b c d e))
-> 0

(position 'f '(a b c d e))
-> NIL