list to values

Started by jopython, December 07, 2012, 06:20:31 PM

Previous topic - Next topic

jopython

Lets say I have a function which accepts 2 strings and three integers

e.g
(myfunc "str1" "str2" 3 4 5)

However I have a list which contains these integer values.

(setq myvalues '(3 4 5))

How can I convert the content of myvalues list to a set of values so that i can pass them to "myfunc" as arguments?

HPW

#1
Like this:


(setq myvalues '(3 4 5))
(myfunc "str1" "str2" (myvalues 0)(myvalues 1)(myvalues 2))


?
Hans-Peter

jopython

#2
HPW,



This is not possible if myvalues has a 'unknown' number of elements.

Lutz

#3
try  using the following three functions:



http://www.newlisp.org/downloads/newlisp_manual.html#apply">http://www.newlisp.org/downloads/newlis ... html#apply">http://www.newlisp.org/downloads/newlisp_manual.html#apply

http://www.newlisp.org/downloads/newlisp_manual.html#append">http://www.newlisp.org/downloads/newlis ... tml#append">http://www.newlisp.org/downloads/newlisp_manual.html#append

http://www.newlisp.org/downloads/newlisp_manual.html#list">http://www.newlisp.org/downloads/newlis ... .html#list">http://www.newlisp.org/downloads/newlisp_manual.html#list

William James

#4

(define (my-func s1 s2 a b c)
  (dup (string s1 s2 a b) c))

> (my-func "o" "-" 1984 9 3)
"o-19849o-19849o-19849"

> (apply my-func (cons "o" (cons "-" '(1984 9 3))))
"o-19849o-19849o-19849"

> (apply my-func (append '("o" "-") '(1984 9 3)))
"o-19849o-19849o-19849"