Assuming you'd like to skip the first line of the file and process the remaining lines as you do in tile-image-across
, you can simply replace (line-seq rdr)
with
(next (line-seq rdr))
In fact, you should probably factor out selecting the relevant lines and the processing:
;; rename repeat-image to repeat-line
(defn read-image [rdr]
(next (line-seq rdr)))
(defn repeat-image! [n lines]
(doseq [line lines]
(repeat-line n line)))
Use inside with-open
:
(with-open [rdr ...]
(repeat-image! (read-image rdr)))
If instead your file holds multiple images and you need to skip the first line of each, the best way would be to write a function to partition the seq of lines into a seq of images (how that'd be done depends on the format of your file), then map that over (line-seq rdr)
and (map next ...))
over the result:
(->> (line-seq rdr)
;; should partition the above into a seq of seqs of lines, each
;; describing a single image:
(partition-into-individual-image-descriptions)
(map next))
NB. with a lazy partition-into-individual-image-descriptions
this will produce a lazy seq of lazy seqs; you'll need to consume them before with-open
closes the reader.