albusshin
albusshin

Reputation: 4010

How to put a string into a list

I want to put the value of an empty string "" into an empty list.

I currently have the idea of (cons "" '()). Is there any other (or better) way to do this?

Upvotes: 1

Views: 184

Answers (2)

amalloy
amalloy

Reputation: 91857

Or indeed just '(""). list is the more general list constructor, since it will evaluate its arguments, but for creating a list of constants, you can use quote (recall that 'x is shorthand for (quote x)).

You should also consider creating a vector instead, with [""]. Vectors are often a better place to store data than lists, in Clojure.

Upvotes: 6

uselpa
uselpa

Reputation: 18917

Use list:

> (list "")
("")

Upvotes: 4

Related Questions