Page 1 of 1

variable list - getting the element

Posted: Sat Sep 22, 2012 12:17 am
by samohtvii
I have a list that only contains 1 element like this

Code: Select all

(setq x ("Thomas")
(somefunction x))

(defun somefunction (x)
(print x))

That's basically the problem I have in my code. I can't paste my code exactly cause a) it's too long and the problem is for a specific bit, prob just mak it more confusing. b) I am running VMWare inside windows so i can't copy and paste between them....anyway,....

I only want to print out the element and not the whole ()'s

output: Thomas
not: ("Thomas") or "Thomas"

Thanks

Re: variable list - getting the element

Posted: Sat Sep 22, 2012 2:57 am
by Goheeca
Easily:

Code: Select all

(defvar *list-with-one-element* '("Thomas"))
(format t "~a" (first *list-with-one-element*))
Some links: the format function and a format string.