David
David

Reputation: 147

how to display only the elements of a list in scheme

(display '(a b c)) returns (a b c) but I am looking for a procedure that takes '(a b c) as an argument and displays a b c instead. Is this possible?

Upvotes: 1

Views: 772

Answers (1)

Óscar López
Óscar López

Reputation: 235994

It's a list of symbols, which has a standard representation: '(a b c). If you want to get rid of the surrounding () we have to manipulate the elements as strings, for example:

(display              ; finally, display the string
 (string-join         ; join the strings using a space as separator
  (map symbol->string ; convert each symbol to a string
       '(a b c))))    ; this is a list of symbols

It'll print:

a b c

Upvotes: 1

Related Questions