diff --git a/src/DataTree.cc b/src/DataTree.cc
index 72ab5a44b9d1cf63a32d83b9c994c9ff5d763a95..58cff3dd07546ac3f57cb1cff1b4952b5bba95dd 100644
--- a/src/DataTree.cc
+++ b/src/DataTree.cc
@@ -24,6 +24,7 @@
 #include <fstream>
 #include <iostream>
 #include <iterator>
+#include <ranges>
 
 #include "DataTree.hh"
 
@@ -804,9 +805,9 @@ DataTree::AddSum(expr_t arg)
 bool
 DataTree::isSymbolUsed(int symb_id) const
 {
-  for (const auto& [symb_lag, expr] : variable_node_map)
-    if (symb_lag.first == symb_id)
-      return true;
+  if (ranges::any_of(views::keys(variable_node_map),
+                     [=](const auto& symb_lag) { return symb_lag.first == symb_id; }))
+    return true;
 
   if (local_variables_table.contains(symb_id))
     return true;
@@ -852,8 +853,8 @@ DataTree::addAllParamDerivId([[maybe_unused]] set<int>& deriv_id_set)
 bool
 DataTree::isUnaryOpUsed(UnaryOpcode opcode) const
 {
-  return ranges::any_of(unary_op_node_map,
-                        [=](const auto& it) { return get<1>(it.first) == opcode; });
+  return ranges::any_of(views::keys(unary_op_node_map),
+                        [=](const auto& key) { return get<1>(key) == opcode; });
 }
 
 bool
@@ -873,8 +874,8 @@ DataTree::isUnaryOpUsedOnType(SymbolType type, UnaryOpcode opcode) const
 bool
 DataTree::isBinaryOpUsed(BinaryOpcode opcode) const
 {
-  return ranges::any_of(binary_op_node_map,
-                        [=](const auto& it) { return get<2>(it.first) == opcode; });
+  return ranges::any_of(views::keys(binary_op_node_map),
+                        [=](const auto& key) { return get<2>(key) == opcode; });
 }
 
 bool
diff --git a/src/DynamicModel.cc b/src/DynamicModel.cc
index bea5e9d733d18e1b8b0368d4b2a1ce3ed7147df3..4f15c20316d20cd1061ad56aab8b998a228b8e16 100644
--- a/src/DynamicModel.cc
+++ b/src/DynamicModel.cc
@@ -1043,14 +1043,8 @@ DynamicModel::writeDriverOutput(ostream& output, bool compute_xrefs) const
          << (static_only_equations.size() > 0) << ";" << endl;
 
   // Say if model contains an external function call
-  bool has_external_function = false;
-  for (auto equation : equations)
-    if (equation->containsExternalFunction())
-      {
-        has_external_function = true;
-        break;
-      }
-  output << "M_.has_external_function = " << boolalpha << has_external_function << ';' << endl;
+  output << "M_.has_external_function = " << boolalpha
+         << ranges::any_of(equations, &ExprNode::containsExternalFunction) << ';' << endl;
 
   // Compute list of state variables, ordered in block-order
   vector<int> state_var;
diff --git a/src/DynareBison.yy b/src/DynareBison.yy
index 609eb9f23587e768e82d3409ea91825efad56d20..ab5d0bc94893dd544d75ba63e8dfc5a629588e46 100644
--- a/src/DynareBison.yy
+++ b/src/DynareBison.yy
@@ -39,6 +39,7 @@ class ParsingDriver;
 #include <utility>
 #include <tuple>
 #include <variant>
+#include <ranges>
 
 #include "CommonEnums.hh"
 #include "ExprNode.hh"
@@ -4470,9 +4471,8 @@ vec_int_number : INT_NUMBER
 vec_int_elem : vec_int_number
              | INT_NUMBER ':' INT_NUMBER
                {
-                 $$ = {};
-                 for (int i = stoi($1); i <= stoi($3); i++)
-                   $$.push_back(i);
+                 auto v = views::iota(stoi($1), stoi($3) + 1);
+                 $$ = {v.begin(), v.end()};
                }
              ;