Use pr-str: user=> (str (lazy-seq (list 1 2 3))) "clojure.lang.LazySeq@7861" user=> (pr-str (lazy-seq (list 1 2 3))) "(1 2 3)"
Cheers, Michał On 15 May 2014 16:29, Phillip Lord <phillip.l...@newcastle.ac.uk> wrote: > > > I am trying to dump a representation of the contents of a list to file. > I've recently changed how I generated this list and it's now lazy (not really > by design more by side-effect, if you will excuse the poor choice of words). > > I was using > > (spit "file" (str lst "\n")) > > which worked quite nicely, but now it is failing. The problem is that I get a > file full of "clojure.lang.LazySeq@" lines. The problem comes from LazySeq > directly, as this demonstration with "range" shows. > > user> (str (list 1 2 3 4 5 )) > "(1 2 3 4 5)" > user> (str (range 4)) > "clojure.lang.LazySeq@e1b83" > user> (println (range 4)) > (0 1 2 3) > nil > > > println is using prn and a multimethod to print out. In fact, > clojure.lang.LazySeq doesn't implement toString, nor does it's super class. > > The best solution that I have come up with so far is to do > > (str (apply list (range 4))) > > I guess I can see why LazySeq doesn't implement toString by printing > everything out, but is there a better way around my problem? > > Phil > > -- > 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 unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.