Partition the data. At its simplest: (doseq [accounts (partition-by first account-funds)] (doseq [account (first h), fund (second h)] (println account fund) (println "-----------"))))
You can also use destructuring to do without the let clause: (doseq [accounts (partition-by first account-funds)] (doseq [[account fund] accounts] (println account fund) (println "-----------"))) And we can merge the two doseqs: (doseq [accounts (partition-by first account-funds), [account fund] accounts] (println account fund) (println "-----------")) On 15 July 2017 at 23:18, Kevin Kleinfelter <kleinfelter.gro...@gmail.com> wrote: > How does one detect a change in a doseq? > > I'm trying to do what data processing people would call a control break in > a report. I'm printing account + fund names. My data is sorted by > account, so each row has a new fund, and accounts change less frequently. > I'd like to print a separator line when account changes. In a procedural > language, I'd set up an old-account variable, and I'd print the separator > line when account != old-account. > > (doseq [h list-of-account-fund-pairs] > (let [account (first h) > fund (second h) > * (if changed-account)* > (println "-----------") > (println account fund) > > Thanks! > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- James Reeves booleanknot.com -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.