Advertisement
CLooker

Untitled

Dec 31st, 2017
1,234
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;;(= (__ [1 2 3 4 5 6 7 8] 3) [1 2 4 5 7 8])
  2.  
  3. (defn indexes-to-remove
  4.   [some-seq rm-idx]
  5.     (loop [x (- rm-idx 1)
  6.           result []]
  7.       (if (< x (count some-seq))
  8.         (let []
  9.           (recur (+ x rm-idx) (conj result x)))
  10.         result)))
  11.      
  12. (defn indexes-removed
  13.   [indexes-to-remove]
  14.   (keep-indexed
  15.     (fn
  16.       [index item]
  17.       (if (contains? indexes-to-remove index)
  18.           nil
  19.           item)
  20.     indexes-to-remove)))
  21.  
  22. (indexes-removed (indexes-to-remove [1 2 3 4 5 6 7 8] 3))
Advertisement
RAW Paste Data Copied
Advertisement