My function works as I expect (I think) but I want to change my loops with higher order functions, but I\'m struggling a bit..
Here is my code :