From dabc227cbe42ee9cdc95ca08f03b5fd5d1f53242 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Tue, 12 Jul 2022 10:38:37 +0200 Subject: [PATCH] hprint:: some extra functions --- hprint.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hprint.cpp b/hprint.cpp index e2789ac0..7789a3a1 100644 --- a/hprint.cpp +++ b/hprint.cpp @@ -231,6 +231,13 @@ template void print(hstream& hs, const vector& a) { print(hs, "("); template void print(hstream& hs, const map& a) { print(hs, "("); comma_printer c(hs); for(auto& t: a) c(t); print(hs, ")"); } +template string separated(string separator, const vector& a) { + shstream ss; + bool first = true; + for(auto& v: a) { if(first) first = false; else print(ss, separator); print(ss, v); } + return ss.s; + } + inline void print(hstream& hs, const hyperpoint h) { print(hs, (const array&)h); } inline void print(hstream& hs, const transmatrix T) { print(hs, "("); comma_printer c(hs); @@ -300,6 +307,10 @@ struct indenter { struct indenter_finish : indenter { explicit indenter_finish(bool b = true): indenter(b ? 2:0) {} + explicit indenter_finish(string s): indenter(2) { + indenter tmp(-2); + println(hlog, s); + } ~indenter_finish() { if(hlog.indentation != ind.backup) println(hlog, "(done)"); } };