variable list - getting the element

Discussion of Common Lisp
Post Reply
samohtvii
Posts: 12
Joined: Thu Aug 23, 2012 11:49 pm

variable list - getting the element

Post by samohtvii » Sat Sep 22, 2012 12:17 am

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

Goheeca
Posts: 271
Joined: Thu May 10, 2012 12:54 pm
Contact:

Re: variable list - getting the element

Post by Goheeca » Sat Sep 22, 2012 2:57 am

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.
cl-2dsyntax is my attempt to create a Python-like reader. My mirror of CLHS (and the dark themed version). Temporary mirrors of aferomentioned: CLHS and a dark version.

Post Reply