'seq' creates a sequence out of almost anything, including strings:
user=> (seq "test")
(\t \e \s \t)
Note this is a lazy seq, though the laziness doesn't matter
much on a string. A seq is not exactly the same as a list,
but will generally do.
--Chouser
> What is the best way to iterate through the characters of a string? Is
> there some kind of EXPLODE function such that:
>
> => (explode "test")
> (\t \e \s \t)
>
> I did a Google search but the closest thing I found was SUBS:
>
> =>(subs "test" 1 2)
> "t"
The key rule is that in Clojure, if a data structure can reasonably be
viewed as a sequence, it can be turned into one. Thus
=> (seq "abcde")
(\a \b \c \d \e)
HTH,
--
Michel Salim
I think we all need to be very careful about calling things sequences
which are not. seq can give you a sequential view of many things, but
that doesn't make those things sequences. Very few of the Clojure data
structures are actual sequences, e.g. vectors, maps, strings etc are
not. Nor do most Clojure collections implement the sequence (ISeq)
interface. They implement the Seqable interface, which means seq
works, and the thing that seq returns implements ISeq. The fact that
first/rest/other-sequence-fns work on most collections falls out of
the fact that they call seq on their args.
It may seem like a nit, but I've seen a lot of confusion, e.g. people
listing The Sequence Types: Vector, Map etc. Each of the data
structures has important and unique characteristics (insertion, lookup
etc) when not used sequentially. It just makes a mess of the
abstractions to call them sequences.
Rich