Skip to content

Instantly share code, notes, and snippets.

@vkz
Created August 18, 2016 17:22
Show Gist options
  • Save vkz/31b3d13c66c19a295a2615c6b69e5ae9 to your computer and use it in GitHub Desktop.
Save vkz/31b3d13c66c19a295a2615c6b69e5ae9 to your computer and use it in GitHub Desktop.
(defn apply-to-column-n
"Apply f only to column N in each table row. Columns start from column 1.
Gracefully do nothing for rows that are too short."
[f N table]
(map (fn [row]
(map (fn [n cell]
(if (= n N)
(f cell)
cell))
(drop 1 (range))
row))
table))
(apply-to-column-n
;; fn
(constantly "bla")
;; column number
2
;; table: sequence of sequences
(read-annotations-from-xls "dev-resources/annotations.xlsx" "annotations"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment