Clojure Remove item from Vector at a Specified Location

后端 未结 8 891
无人共我
无人共我 2020-12-04 01:35

Is there a way to remove an item from a vector based on index as of now i am using subvec to split the vector and recreate it again. I am looking for the reverse of assoc fo

8条回答
  •  借酒劲吻你
    2020-12-04 01:58

    Here is a solution iv found to be nice:

    (defn index-exclude [r ex] 
       "Take all indices execpted ex" 
        (filter #(not (ex %)) (range r))) 
    
    
    (defn dissoc-idx [v & ds]
       (map v (index-exclude (count v) (into #{} ds))))
    
    (dissoc-idx [1 2 3] 1 2)
    
    
    '(1)
    

提交回复
热议问题