How to print the intermediate values in a transient vector?

2020-06-25 Thread Philos Kim
How can I print the intermediate values in a transient vector?

I tried this but the printed result is like this and it is not what I want 
to see.


(let [v (transient [])]
  (dotimes [n 3]
(conj! v n)
(println v)))
;; printed v
#object[clojure.lang.PersistentVector$TransientVector 0x162d8132 
clojure.lang.PersistentVector$TransientVector@162d8132]
#object[clojure.lang.PersistentVector$TransientVector 0x162d8132 
clojure.lang.PersistentVector$TransientVector@162d8132]
#object[clojure.lang.PersistentVector$TransientVector 0x162d8132 
clojure.lang.PersistentVector$TransientVector@162d8132]

So I retried like this but failed with an exception.

(let [v (transient [])]
  (dotimes [n 3]
(conj! v n)
(persistent! v)
(println v)))
IllegalAccessError Transient used after persistent! call  
clojure.lang.PersistentVector$TransientVector.ensureEditable 
(PersistentVector.java:548)

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/clojure/7a4ca9be-40a8-4f56-b9dc-0622855ae2e9o%40googlegroups.com.


How to print the intermediate values in a transient vector?

2020-06-25 Thread Philos Kim
How can I print the *intermediate values* in a transient vector?

I tried this but the printed result is not what I want to see.

(let [v (transient [])]
  (dotimes [n 3]
(conj! v n)
(println v)))
;; printed v
#object[clojure.lang.PersistentVector$TransientVector 0x162d8132 
clojure.lang.PersistentVector$TransientVector@162d8132]
#object[clojure.lang.PersistentVector$TransientVector 0x162d8132 
clojure.lang.PersistentVector$TransientVector@162d8132]
#object[clojure.lang.PersistentVector$TransientVector 0x162d8132 
clojure.lang.PersistentVector$TransientVector@162d8132]

So I retried like this but failed with an exception.

(let [v (transient [])]
  (dotimes [n 3]
(conj! v n)
(persistent! v)
(println v)))
IllegalAccessError Transient used after persistent! call  
clojure.lang.PersistentVector$TransientVector.ensureEditable 
(PersistentVector.java:548)

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/clojure/872b0aa3-033b-4ea2-b19b-02e9ca4875b2o%40googlegroups.com.