* elisp: how to pass a list argument to defun
@ 2006-06-28 9:36 lalit mohan tripathi
0 siblings, 0 replies; 4+ messages in thread
From: lalit mohan tripathi @ 2006-06-28 9:36 UTC (permalink / raw)
[-- Attachment #1.1: Type: text/plain, Size: 857 bytes --]
Hi All,
Could anyone tell me how to pass a list argument in elisp to a defun?
I'm want to write a defun like this
(defun process-list-fn (list02, a, b, c)
"This function prints the list02, a, b, c."
(print list02)
(print a)
(print b)
(print c))
I want to use it like this:
(setq list01 '("abc" "def" "xyz"))
(process-list-fn list01 10 20 30)
But I get the following error:
Debugger entered--Lisp error: (void-variable list02)
(print list02)
process-list-fn(("abc" "def" "xyz") 10 20 30)
eval((process-list-fn list01 10 20 30))
eval-last-sexp-1(nil)
eval-last-sexp(nil)
call-interactively(eval-last-sexp)
recursive-edit()
byte-code("Æ\b!^[,HG^[(B ^[,HH ^[(B!^[,H\^[(Bn^[,C?
P.S. I'm able to pass the list to a function but that works when the defun
is defined with only one listarguement.
[-- Attachment #1.2: Type: text/html, Size: 1161 bytes --]
[-- Attachment #2: Type: text/plain, Size: 152 bytes --]
_______________________________________________
help-gnu-emacs mailing list
help-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <mailman.3433.1151487404.9609.help-gnu-emacs@gnu.org>]
* Re: elisp: how to pass a list argument to defun
[not found] <mailman.3433.1151487404.9609.help-gnu-emacs@gnu.org>
@ 2006-06-28 10:03 ` Tassilo Horn
2006-06-28 13:55 ` Pascal Bourguignon
2006-06-28 20:59 ` Le Wang
2 siblings, 0 replies; 4+ messages in thread
From: Tassilo Horn @ 2006-06-28 10:03 UTC (permalink / raw)
"lalit mohan tripathi" <lalit.tripathi@gmail.com> writes:
Hi!
> (defun process-list-fn (list02, a, b, c)
> "This function prints the list02, a, b, c."
> (print list02)
> (print a)
> (print b)
> (print c))
>
> (setq list01 '("abc" "def" "xyz"))
> (process-list-fn list01 10 20 30)
>
> But I get the following error:
>
> Debugger entered--Lisp error: (void-variable list02)
Lisp doesn't know the variable `list02', but it knows `list02,'. ;-)
In Lisp you don't separate the parameters with comma. Remove them and
you'll be fine.
Bye,
Tassilo
--
VI VI VI - The Roman Number Of The Beast
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: elisp: how to pass a list argument to defun
[not found] <mailman.3433.1151487404.9609.help-gnu-emacs@gnu.org>
2006-06-28 10:03 ` Tassilo Horn
@ 2006-06-28 13:55 ` Pascal Bourguignon
2006-06-28 20:59 ` Le Wang
2 siblings, 0 replies; 4+ messages in thread
From: Pascal Bourguignon @ 2006-06-28 13:55 UTC (permalink / raw)
"lalit mohan tripathi" <lalit.tripathi@gmail.com> writes:
> Hi All,
> Could anyone tell me how to pass a list argument in elisp to a defun?
> I'm want to write a defun like this
> (defun process-list-fn (list02, a, b, c)
> "This function prints the list02, a, b, c."
> (print list02)
> (print a)
> (print b)
> (print c))
> I want to use it like this:
> (setq list01 '("abc" "def" "xyz"))
> (process-list-fn list01 10 20 30)
(defun process-list-fn (list02, a, b, c)
"This function prints the list02, a, b, c."
(print list02,)
(print a,)
(print b,)
(print c))
(process-list-fn 'list01 10 20 30)
prints:
list01
10
20
30
returns:
30
--
__Pascal Bourguignon__ http://www.informatimago.com/
CAUTION: The mass of this product contains the energy equivalent of
85 million tons of TNT per net ounce of weight.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: elisp: how to pass a list argument to defun
[not found] <mailman.3433.1151487404.9609.help-gnu-emacs@gnu.org>
2006-06-28 10:03 ` Tassilo Horn
2006-06-28 13:55 ` Pascal Bourguignon
@ 2006-06-28 20:59 ` Le Wang
2 siblings, 0 replies; 4+ messages in thread
From: Le Wang @ 2006-06-28 20:59 UTC (permalink / raw)
lalit mohan tripathi wrote:
> Hi All,
>
> Could anyone tell me how to pass a list argument in elisp to a defun?
>
> I'm want to write a defun like this
>
> (defun process-list-fn (list02, a, b, c)
> "This function prints the list02, a, b, c."
> (print list02)
> (print a)
> (print b)
> (print c))
>
>
> I want to use it like this:
>
> (setq list01 '("abc" "def" "xyz"))
> (process-list-fn list01 10 20 30)
>
> But I get the following error:
>
> Debugger entered--Lisp error: (void-variable list02)
> (print list02)
> process-list-fn(("abc" "def" "xyz") 10 20 30)
> eval((process-list-fn list01 10 20 30))
> eval-last-sexp-1(nil)
> eval-last-sexp(nil)
> call-interactively(eval-last-sexp)
> recursive-edit()
> byte-code("?\b!?HG ?HH !?H\n?C?
>
> P.S. I'm able to pass the list to a function but that works when the defun
> is defined with only one listarguement.
remove the commas from your defun formal parameters list.
--
Le
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-06-28 20:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-28 9:36 elisp: how to pass a list argument to defun lalit mohan tripathi
[not found] <mailman.3433.1151487404.9609.help-gnu-emacs@gnu.org>
2006-06-28 10:03 ` Tassilo Horn
2006-06-28 13:55 ` Pascal Bourguignon
2006-06-28 20:59 ` Le Wang
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.