Qual è il modo più semplice per creare un vettore di riferimenti distinti?Clojure Vector of Refs
Utilizzando (repeat 5 (ref nil))
restituirà un elenco, ma saranno tutti riferimento allo stesso ref:
user=> (repeat 5 (ref nil))
(#<[email protected]: nil> #<[email protected]: nil> #<[email protected]: nil> #<[email protected]: nil> #<R
[email protected]: nil>)
stesso risultato con (replicate 5 (ref nil))
:
user=> (replicate 5 (ref nil))
(#<[email protected]: nil> #<[email protected]: nil> #<[email protected]: nil> #<[email protected]: nil>
#<[email protected]: nil>)
e poi avvolgere in (vec (prendere 5 (ripetutamente # (ref nil)))) –