all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* build-in function for obtaining the index of an element of a list
@ 2012-01-04  6:33 ishi soichi
  2012-01-04 12:51 ` Juanma Barranquero
  0 siblings, 1 reply; 3+ messages in thread
From: ishi soichi @ 2012-01-04  6:33 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 379 bytes --]

I have a question about Emacs Lisp.

Is there any Emacs built-in function that returns the index of an element
of a list?

More specifically, say I have a list

(setq lista '("apple" "banana" "orange))

then implement the function, which I want,

(functionName lista "banana")    ; => 1

If not, please give me an example of such function definition.

Thanks in advance!

soichi

[-- Attachment #2: Type: text/html, Size: 618 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: build-in function for obtaining the index of an element of a list
  2012-01-04  6:33 build-in function for obtaining the index of an element of a list ishi soichi
@ 2012-01-04 12:51 ` Juanma Barranquero
  2012-01-04 23:52   ` ishi soichi
  0 siblings, 1 reply; 3+ messages in thread
From: Juanma Barranquero @ 2012-01-04 12:51 UTC (permalink / raw)
  To: ishi soichi; +Cc: help-gnu-emacs

> Is there any Emacs built-in function that returns the index of an element of
> a list?

If you don't mind using the CL package (included with Emacs), the
function you want is `position'

 (position "banana" '("apple" "banana" "orange") :test 'string=)   =>  1

    Juanma



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: build-in function for obtaining the index of an element of a list
  2012-01-04 12:51 ` Juanma Barranquero
@ 2012-01-04 23:52   ` ishi soichi
  0 siblings, 0 replies; 3+ messages in thread
From: ishi soichi @ 2012-01-04 23:52 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 381 bytes --]

Thanks. This is what I wanted.

soichi

2012/1/4 Juanma Barranquero <lekktu@gmail.com>

> > Is there any Emacs built-in function that returns the index of an
> element of
> > a list?
>
> If you don't mind using the CL package (included with Emacs), the
> function you want is `position'
>
>  (position "banana" '("apple" "banana" "orange") :test 'string=)   =>  1
>
>     Juanma
>

[-- Attachment #2: Type: text/html, Size: 804 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-01-04 23:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-04  6:33 build-in function for obtaining the index of an element of a list ishi soichi
2012-01-04 12:51 ` Juanma Barranquero
2012-01-04 23:52   ` ishi soichi

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.