It's because functions such as reduce, map, reverse, etc. only work on
sequences, so they have to call seq on that argument. Strings just
happen to be seq-able but calling seq on one returns a list of
characters, so the result is one too. Reverse always returns a
sequence and strings aren't technically sequences, so that's why it
doesn't convert the characters back into a string.

On Wednesday, July 20, 2011, Basi Lambanog <restyc...@gmail.com> wrote:
> Hello,
> Any reason for the change in type after some operations, for example:
>
> user=>
> (type (reverse "abc"))
> clojure.lang.PersistentList
>
> user=>
> (type "abc")
> java.lang.String
>
> Since reverse operates on a string, shouldn't the result be a string
> as well? There's a few more of these type re-casting after an
> operation.
>
> Tuba
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to