(join (args)) and mixed data types?

Q&A's, tips, howto's
Locked
axtens
Posts: 28
Joined: Mon Apr 06, 2009 12:23 pm
Location: Perth, WA Australia
Contact:

(join (args)) and mixed data types?

Post by axtens »

G'day everyone

Pardon my naivete, but I'm having trouble with (join (args)) in that I'm expecting to get a string out of it, but it fails when items in the args are non-string.

For example

Code: Select all

(define (tracer)
	(begin
		(set 'str (join (args)))
		(append-file "trace.log" str)
		(print str)
	)
)

(tracer 1 0.2 "do" " " "not")
Out of that I get the following error message

Code: Select all

ERR: string expected : 1
called from user defined function tracer
How do I make (tracer) sufficiently generic such that it can handle anything (or almost anything) that it receives in the args list?

Kind regards,
Bruce.

Kazimir Majorinc
Posts: 388
Joined: Thu May 08, 2008 1:24 am
Location: Croatia
Contact:

Post by Kazimir Majorinc »

Try something in the style of

(set 'str (join (map string (args))))

Locked