variable list - getting the element

Discussion of Common Lisp

variable list - getting the element

Postby 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"

Posts: 12
Joined: Thu Aug 23, 2012 11:49 pm

Re: variable list - getting the element

Postby Goheeca » Sat Sep 22, 2012 2:57 am

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).
User avatar
Posts: 165
Joined: Thu May 10, 2012 12:54 pm

Return to Common Lisp

Who is online

Users browsing this forum: No registered users and 1 guest