What I have:
- Collection (map in this instance, Seqable more generally) of items I want to display in a Markdown table (whichever flavour of Markdown reddit uses).
- Sequence of accessor functions that produce the contents of each column of the desired table when mapped over the collection.
- Sequence of those column mappings:
(for [x accessors] (map x coll))
What I'm trying to do:
- Append
(repeat "\n")to the sequence of mappings, as the item separator. apply interleaveover the sequence-of-sequences.- Consume the resulting sequence with
clojure.string/jointo insert the 'table cell separator' "|" and glue it all together.
I just can't seem to get the first step working. All my attempts seem to append the infinite sequence of \n itself rather than that sequence as a single object in a seq of seqs or similar issues. A little help?
Edit: A little input/output example does make sense for something like this so I'd better add it. For simplicity we'll just list numbers and functions of them. Input:
(markdown-table [[[identity] "Number"]
[[(partial * 2)] "Doubled"]] (range 6))
(The strings and such are for making column names - might change that setup later but you can see the accessor functions in there. Just listing the number itself and its doubling.)
For this I have the sequence ((0 1 2 3 4 5) (0 2 4 6 8 10)) and want to end up with the sequence
(0 0 "\n" 1 2 "\n" 2 4 "\n" 3 6 "\n" 4 8 "\n" 5 10 "\n")