Try including [*print-dup* true] in the binding;

(defn write-nick-sets [file-name obj]]
  (with-open [w (FileWriter. (File. file-name))]
    (binding [*out* w *print-dup* true] (prn obj))))

You can read it back with;

(defn rec-load
  "Load a clojure form from file"
  [#^File file]
  (with-open [r (PushbackReader. (FileReader. file))]
    (let [rec (read r)]
      rec)))

See clojure.core_print.clj in the clojure source for details.

-Regards, Adrian.


On Thu, Feb 25, 2010 at 5:17 AM, NovusTiro <novust...@gmail.com> wrote:
> I'm trying to prn a large data structure to a file so I can later read
> it back in, like so -
>
> (defn write-nick-sets [file-name obj]
>  (binding [*out* (java.io.FileWriter. file-name)]
>    (prn obj)))
>
> obj here is a map with a string as its key and another map as its
> value.  The nested map has a list as its key and a set as its value.
> When I prn the structure to a file as above, it doesn't print out all
> my data, only 40 key-value pairs for each nested map are printed, and
> an ellipsis is inserted after them (I guess to represent the
> remainder).
>
> Anyone know what I'm doing wrong here?  How can I print the whole data
> structure to a file, in a way that the reader can understand?
>
> --
> 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