How to find the position of atom in the list

Discussion of Common Lisp
Post Reply
bokshi
Posts: 2
Joined: Mon Nov 07, 2011 8:35 am

How to find the position of atom in the list

Post by bokshi » Mon Nov 07, 2011 11:15 am

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.

krzysz00
Posts: 4
Joined: Mon Nov 07, 2011 5:10 pm

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

Post by krzysz00 » Mon Nov 07, 2011 8:02 pm

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

Post Reply