Wykorzystanie transjentów Clojure

Jestem trochę zagubiony w używaniu transjentów w clojure. Każda pomoc zostanie doceniona. Przykładowy kod:

(defn test-transient [v]
    (let [b (transient [])]
        (for [x v] (conj! b x))
        (persistent! b)))

user> (test-transient [1 2 3])
[]

Próbowałem uczynić go trwałym przed powrotem, a wynikiem jest:

(defn test-transient2 [v]
    (let [b (transient [])]
        (for [x v] (conj! b x))
        (persistent! b)
        b))

user> (test-transient2 [1 2 3])
#<TransientVector clojure.lang.PersistentVector$TransientVector@1dfde20>

Ale jeśli użyję spójnika! oddzielnie wygląda na to, że działa dobrze:

(defn test-transient3 [v]
    (let [b (transient [])]
    (conj! b 0)
    (conj! b 1)
    (conj! b 2)
    (persistent! b)))

user> (test-transient3 [1 2 3])
[0 1 2]

Czy ma jakieś ograniczenia? Jeśli tak, jak mogę skopiować wartości z trwałego wektora do przemijającego?

Dziękuję Ci.

questionAnswers(1)

yourAnswerToTheQuestion