                   [:td [:input#submit
                         {:value "Display pdgms", :name "submit", :type "submit"}]]]])))
 
+(defn addpnum
+  [valclusters]
+  (let [pnum (atom 0)]
+    (for [valcluster valclusters]
+      (let [pnum (swap! pnum inc)]
+        (clojure.string/replace valcluster #"\r\n(\S)" (str "\r\nP-"  pnum  ",$1"))))))
+
 (defn vc2req
  [valclusters pos]
   (let [vcvec (split valclusters #" ")
-        lprefmap (read-string (slurp "pvlists/lprefs.clj"))]
+        lprefmap (read-string (slurp "pvlists/lprefs.clj"))
+        pmnum (atom 0)
+        pdgmnums (into [] (take (count vcvec) (iterate inc 1)))
+        ]
     (for [valcluster vcvec]
-      (let [vals (split valcluster #"," 2)
+      (let [;;valcluster (nth vcvec (dec pdgmnum))
+            vals (split valcluster #"," 2)
             language (first vals)
             vcluster (last vals)
+            ;; all three of following fail to recalculate after 1st iteration
+            pnum (.indexOf valclusters valcluster)
+            pmnum (swap! pmnum inc)
+            pdnum (nth pdgmnums pnum)
             lang (read-string (str ":" language))
             lpref (lang lprefmap)
             valstrng (clojure.string/replace vcluster #",*person|,*gender|,*number" "")

           ;;)
       ))]]]))
        

(defn handle-multimoddisplay
  [valclusters pos]
  ;; send SPARQL over HTTP request
  (let [headerset1 (str "Paradigm " "Number " "Person " "Gender " "Token ")
        headerset2 (str "pdgm " "num " "pers " "gen ")
        headers (split headerset2 #" ")
        pdgmvec (map #(vc2req  % pos) valclusters)
        header (first pdgmvec)
        pdgmstr1 (apply pr-str pdgmvec)

                       {"query" query-sparql ;;generated sparql
                        ;;"format" "application/sparql-results+json"}})]
                        "format" "csv"}})
            ;; get rid of header
            pbody (clojure.string/replace (:body req) #"^.*?\r\n" "\r\n")
            ]
        ;; add pdgm name to each row of pbody as first value
        (clojure.string/replace pbody #"\r\n(\S)" (str "\r\n" vcstring  ",$1"))))))

(defn csv2pdgm
"Takes sorted 4-col csv list with vectors of pnames and headers, and outputs 5-col html table with first col for pname ref; cols are draggable and sortable."
