Page 1 of 1

How to find the position of atom in the list

Posted: Mon Nov 07, 2011 11:15 am
by bokshi
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

Posted: Mon Nov 07, 2011 8:02 pm
by krzysz00
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:

Code: Select all

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

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