Edit:
The data really looks like this.
1,000-00-000,GRABBUS,OCTOPUS,,M,26-Nev-12,,05 FRENCH TOAST ROAD,,VACANT,ZA,1867,(001) 111-1011,(002) 111-1000,,
I've got to make it look silly, because it contains proprietary information.
This is what it looks like before using clojure-csv to create a vector of vectors.
I used post-parsed numbers to make it easy, but they're not being reduced to a value. I want to cherry pick certain columns from the clojure-csv parsed data and create a smaller csv row.
Please accept my apologies for any confusion.
End Edit:
How do you make a determination of when to use reduce or instead use pmap?
A while ago, I got a comment on my blog concerning reduce. Specifically the comment said reduce in general could not be parallelized, but map (pmap) could be.
When would using or not using reduce make a difference, and for examples like the following, does it make a difference?
Thank You.
(def csv-row [1 2 3 4 5 6 7 8 9])
(def col-nums [0 1 4])
(defn reduce-csv-rowX
"Accepts a csv-row and a list of columns to extract, and
reduces the csv-row to the selected list using a list comprehension."
[csv-row col-nums]
(for [col-num col-nums
:let [part-row (nth csv-row col-num nil)]]
part-row))
(defn reduce-csv-row
"Accepts a csv-row and a list of columns to extract, and
reduces the csv-row to the selected list."
[csv-row col-nums]
(reduce
(fn [out-csv-row col-num]
(let [out-val (nth csv-row col-num nil)]
(if-not (nil? out-val)
(conj out-csv-row out-val))))
[]
col-nums))
Edit:
(defn reduce-csv-row "Accepts a csv-row and a list of columns to extract, and reduces the csv-row to the selected list." [csv-row col-nums] (reduce (fn [out-csv-row col-num] (let [out-val (nth csv-row col-num nil)] (conj out-csv-row out-val))) [] col-nums))