From: learninglisp
Subject: Use keyword-list as argument for a function (?)
Date: 
Message-ID: <878x03884z.fsf@mytrashmail.com>
hi lispers, :)

hmmm, I'm learning Lisp and wondering how to deal with the following
case:

f.e. I have a function with a lot of keywords as arguments:

(defun foo (&key one two three four five six)
    (do-something.. ))

now, somewhere else in my code I have constructed a list with all
needed arguments: 

(setf myparameter 
      '(:one 1 :two 2 :three "three" :four 4 :five "five" :six 6))

what would be the best way to call that function with that prepared
list?

Something like (incorrect): 

(foo ,@myparameter) 

thanks for any help!

   okflo

From: blandest
Subject: Re: Use keyword-list as argument for a function (?)
Date: 
Message-ID: <690baef4-9c9e-495e-9965-883ec2d95028@h11g2000prf.googlegroups.com>
On Mar 28, 12:17 pm, learninglisp <············@mytrashmail.com>
wrote:
> hi lispers, :)
>
> hmmm, I'm learning Lisp and wondering how to deal with the following
> case:
>
> f.e. I have a function with a lot of keywords as arguments:
>
> (defun foo (&key one two three four five six)
>     (do-something.. ))
>
> now, somewhere else in my code I have constructed a list with all
> needed arguments:
>
> (setf myparameter
>       '(:one 1 :two 2 :three "three" :four 4 :five "five" :six 6))
>
> what would be the best way to call that function with that prepared
> list?
>
> Something like (incorrect):
>
> (foo ,@myparameter)
>
> thanks for any help!
>
>    okflo

Try (apply 'foo myparameter)
From: learninglisp
Subject: Re: Use keyword-list as argument for a function (?)
Date: 
Message-ID: <871w5v876y.fsf@mytrashmail.com>
blandest <··············@gmail.com> writes:

> On Mar 28, 12:17 pm, learninglisp <············@mytrashmail.com>
> wrote:
>> f.e. I have a function with a lot of keywords as arguments:
>>
>> (defun foo (&key one two three four five six)
>>     (do-something.. ))
>>
>> now, somewhere else in my code I have constructed a list with all
>> needed arguments:
>>
>> (setf myparameter
>>       '(:one 1 :two 2 :three "three" :four 4 :five "five" :six 6))
>>
>> what would be the best way to call that function with that prepared
>> list?
>>
>> Something like (incorrect):
>>
>> (foo ,@myparameter)
>
> Try (apply 'foo myparameter)
>

ooohhh - of course, why shouldn't work apply also with keyword-lists! 

- thanks for you help! :)

    okflo

CL-USER>  (defun foo (&key one two three four five six)
	    (list one two three four five six))
FOO
CL-USER> (setf my '(:one 1 :two 2 :three "three" :four 4 :five "five" :six 6))
(:ONE 1 :TWO 2 :THREE "three" :FOUR 4 :FIVE "five" :SIX 6)
CL-USER> (apply #'foo my)
(1 2 "three" 4 "five" 6)
From: Ken Tilton
Subject: Re: Use keyword-list as argument for a function (?)
Date: 
Message-ID: <47ecc994$0$5623$607ed4bc@cv.net>
learninglisp wrote:
> hi lispers, :)
> 
> hmmm, I'm learning Lisp and wondering how to deal with the following
> case:
> 
> f.e. I have a function with a lot of keywords as arguments:
> 
> (defun foo (&key one two three four five six)
>     (do-something.. ))
> 
> now, somewhere else in my code I have constructed a list with all
> needed arguments: 
> 
> (setf myparameter 
>       '(:one 1 :two 2 :three "three" :four 4 :five "five" :six 6))
> 
> what would be the best way to call that function with that prepared
> list?
> 
> Something like (incorrect): 
> 
> (foo ,@myparameter) 

(apply 'foo myparameter)

kenny

-- 
http://smuglispweeny.blogspot.com/
http://www.theoryyalgebra.com/

"In the morning, hear the Way;
  in the evening, die content!"
                     -- Confucius
From: ·················@gmail.com
Subject: Re: Use keyword-list as argument for a function (?)
Date: 
Message-ID: <08508f5e-b7f6-40c6-ad61-418586779941@s37g2000prg.googlegroups.com>
On Mar 28, 3:17 am, learninglisp <············@mytrashmail.com> wrote:
> hi lispers, :)
>
> hmmm, I'm learning Lisp and wondering how to deal with the following
> case:
>
> f.e. I have a function with a lot of keywords as arguments:
>
> (defun foo (&key one two three four five six)
>     (do-something.. ))
>
> now, somewhere else in my code I have constructed a list with all
> needed arguments:
>
> (setf myparameter
>       '(:one 1 :two 2 :three "three" :four 4 :five "five" :six 6))
>
> what would be the best way to call that function with that prepared
> list?
>
> Something like (incorrect):
>
> (foo ,@myparameter)
>
> thanks for any help!
>
>    okflo

Try (untested)

(apply #'foo myparameters)

HTH
From: j.oke
Subject: Re: Use keyword-list as argument for a function (?)
Date: 
Message-ID: <5550c6fd-a973-496b-86ba-943e23f34deb@z38g2000hsc.googlegroups.com>
> I'm learning Lisp

(Jon?)
From: Joost Diepenmaat
Subject: Re: Use keyword-list as argument for a function (?)
Date: 
Message-ID: <87od8x4rkd.fsf@zeekat.nl>
learninglisp <············@mytrashmail.com> writes:

> hi lispers, :)
>
> hmmm, I'm learning Lisp and wondering how to deal with the following
> case:
>
> f.e. I have a function with a lot of keywords as arguments:
>
> (defun foo (&key one two three four five six)
>     (do-something.. ))
>
> now, somewhere else in my code I have constructed a list with all
> needed arguments: 
>
> (setf myparameter 
>       '(:one 1 :two 2 :three "three" :four 4 :five "five" :six 6))
>
> what would be the best way to call that function with that prepared
> list?

(apply #'foo myparameter)

works for any parameter list, keywords or not.

http://www.lispworks.com/documentation/HyperSpec/Body/f_apply.htm#apply

Cheers,
Joost.

-- 
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/