Thank you for your reply, it does takes a little more knowledge for a newcomer to have that approach but it is a clean one.
I’ve added your reply has another solution and will take some of your point into account when writing more about the topic.
Thank you! ^^
TL;DR: As long as the code is more readable there is no problem in using
foreach, specially when few mutations are happening, it is always better to have a code that is stupid easy to understand than to have a unnecessary abstraction just because “I want to force everything to be functional”.
Thanks for the feedback! ^^