From c0f818a9e60c4f550ccd91b095260197f1e0cd45 Mon Sep 17 00:00:00 2001
From: Houtan Bastani <houtan@dynare.org>
Date: Thu, 4 May 2017 16:50:19 +0200
Subject: [PATCH] preprocessor: aesthetic fix: make writing to .m file nicer

---
 ComputingTasks.cc | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/ComputingTasks.cc b/ComputingTasks.cc
index c51a29ed..7a8fe14d 100644
--- a/ComputingTasks.cc
+++ b/ComputingTasks.cc
@@ -221,8 +221,19 @@ VarModelStatement::createVarModelMFunction(ostream &output, const map<string, se
   stringstream ss;
   set<int> horizons = var_expectation_functions_to_write.find(name)->second;
   for (set<int>::const_iterator it = horizons.begin(); it != horizons.end(); it++)
-    ss << *it << " ";
-  output << "writeVarExpectationFunction('" << name << "', [" << ss.rdbuf() << "]);" << endl;
+    {
+      if (it != horizons.begin())
+        ss << " ";
+      ss << *it;
+    }
+
+  output << "writeVarExpectationFunction('" << name << "', ";
+  if (horizons.size() > 1)
+    output << "[";
+  output << ss.rdbuf();
+  if (horizons.size() > 1)
+    output << "]";
+  output << ");" << endl;
 }
 
 StochSimulStatement::StochSimulStatement(const SymbolList &symbol_list_arg,
-- 
GitLab