I've got a lazy sequence that, when sent to println, shows like this:
(((red dog) (purple cat)) ((green mouse) (yellow bird)))
Note that this is the result of reading a csv and trimming all "cell" values, hence (a) the fact that it's lazy at the time I want to print it and (b) in the future innermost lists might be more than 2 strings because more columns are added.
I'm trying to juse clojure.pprint/print-table to print this in a two-column table. I'm having a pretty hard time because print-table seems to want a map with data.
Here's a repro:
;; Mock the lazy data retrieved from a csv file
(defn get-lazy-data []
  (lazy-seq '('('("red" "dog") '("purple" "cat")) '('("green" "mouse") '("yellow" "bird")))))
(defn -main []
  (let [data       (get-lazy-data)]
      (println "Starting...")
      (println data)
      (println "Continuing...")
      (print-table data)
      (println "Finished!")))
This gives an error:
Exception in thread "main" java.lang.ClassCastException: clojure.lang.Symbol cannot be cast to java.util.Map$Entry
I've tried various options:
- (print-table (apply hash-map data))gives same exception
- (print-table (zipmap data))tells me to provide another argument for the keys, but I want a solution that doesn't rely on specifying the number of columns beforehand
- comprehending and adapting the answer to "Clojure printing lazy sequence", which would be a duplicate of my question were it not that both the question and answer seem so much more complex that I don't know how to translate that solution to my own scenario
Basically I know I have an XY-problem but now I want answers to both questions:
- X: How do I pretty print a lazy sequence of pairs of pairs of strings as a table on the console?
- Y: How can I convert a lazy sequence to a map (where e.g. keys are the indexes)?
 
     
    