[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: elisp: how to find an ELT is present an ARRAY or not?

From: Yagnesh Raghava Yakkala
Subject: Re: elisp: how to find an ELT is present an ARRAY or not?
Date: Fri, 09 Dec 2011 05:20:14 +0900
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux)

Valentin Baciu <address@hidden> writes:

> On Wed, Dec 7, 2011 at 3:39 PM,  <address@hidden> wrote:
>> I am just trying to verify if an element is present in an array or not.
>> here is what I tried,
>> (let ((arr '[AAA BBB CCC]))
>>  (mapc (lambda (s)
>>          (if (string= "AAA" s)
>>              (insert "AAA is a member of arr")))
>>        arr))
>> if I eval the above
>> return value is: [AAA BBB CCC] and inserts  "AAA is a member of arr" in
>> the buffer
>> But the approach seems wrong to me. Because it loops over all the
>> elements no matter ELT is in it or not and the return value is useless
>> (at least in this case)
>> here is what I really want to achieve:
>> 1) search the array if the element is present
>> 2) if the element is present return "t" otherwise "nil"
>> 3) Since the number of elements in my array will be huge, break the loop
>>  and return "t", if it the function find the first occurrence of ELT
>> Thanks
>> --
>> YYR
> (when (find "AAA" '[AAA BBB CCC] :test 'string=)
>   (insert "Found"))

thats the one I wanted (which is in cl package)

Thanks. more questions to come

reply via email to

[Prev in Thread] Current Thread [Next in Thread]