all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Yagnesh Raghava Yakkala <yagnesh@live.com>
To: help-gnu-emacs@gnu.org
Subject: Re: elisp: how to find an ELT is present an ARRAY or not?
Date: Fri, 09 Dec 2011 05:20:14 +0900	[thread overview]
Message-ID: <8739cug6ip.fsf@live.com> (raw)
In-Reply-To: CAKHQLnpwyTXoTdOn-O98DqjxVc+zEVdQYDkD_7NdO8QV5Ws_-Q@mail.gmail.com

Valentin Baciu <valentin@syntactic.org> writes:

> On Wed, Dec 7, 2011 at 3:39 PM,  <yagnesh@live.com> 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
-- 
YYR




      reply	other threads:[~2011-12-08 20:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-07 13:39 elisp: how to find an ELT is present an ARRAY or not? yagnesh
2011-12-07 13:44 ` Valentin Baciu
2011-12-08 20:20   ` Yagnesh Raghava Yakkala [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8739cug6ip.fsf@live.com \
    --to=yagnesh@live.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.