Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defn displace [v left right x where]
- (let [y (subvec v 0 left) ; levo od nego
- z (subvec v right) ; desno od nego
- removed (apply conj y z) ; celiot vektor bez delot za premestuvanje
- left-vec (subvec removed 0 where)
- right-vec (subvec removed where)
- ]
- (apply conj (apply conj left-vec x) right-vec)
- )
- )
- (defn displacement [v]
- (let [a (int (rand numcities))
- b (int (rand numcities))
- left (min a b) ;leva granica
- right (max a b) ;desna granica
- size (- right left)
- where (int (rand (- numcities size)))
- x (subvec v left right)
- ]
- (displace v left right x where)
- )
- )
- (defn swap [v i1 i2]
- (assoc v i2 (v i1) i1 (v i2)))
- (defn exchange [v]
- (let [a (int (rand numcities))
- b (int (rand numcities))]
- (swap v a b)
- )
- )
- (defn insertion [v]
- (let [left (int (rand numcities))
- right (inc left)
- where (int (rand numcities))
- x (subvec v left right)
- ]
- (displace v left right x where)
- )
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement