From bee8344fdfaf5998c53b6bf1788b4ecd3dac27f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Gil=20de=20G=C3=B3mez=20P=C3=A9rez?= Date: Wed, 12 Aug 2026 17:04:54 +0300 Subject: [PATCH] Solved: 10 - Function Basics --- modules/03_functions/src/function_basics.cpp | 24 ++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/modules/03_functions/src/function_basics.cpp b/modules/03_functions/src/function_basics.cpp index e6b2246..455697d 100644 --- a/modules/03_functions/src/function_basics.cpp +++ b/modules/03_functions/src/function_basics.cpp @@ -1,10 +1,26 @@ #include "function_basics.hpp" +#include + namespace functions { -auto square(int value) -> int { (void)value; return 0; } -void swap_integers(int& lhs, int& rhs) { (void)lhs; (void)rhs; } -auto concatenate(const std::vector& parts) -> std::string { (void)parts; return {}; } -void append_suffix(std::string& text, const std::string& suffix) { (void)text; (void)suffix; } +auto square(const int value) -> int { + return value * value; +} + +void swap_integers(int& lhs, int& rhs) { + const int tmp = lhs; + lhs = rhs; + rhs = tmp; +} + +auto concatenate(const std::vector& parts) -> std::string { + return std::ranges::to(std::views::join(parts)); +} + +void append_suffix(std::string& text, const std::string& suffix) { + // The string is passed by reference, so it can have text appended + text += suffix; +} } // namespace functions