Changing from for loop to functional style


#1

can somebody please help me out with this problem:


Thanks.


#2

Is there anything wrong with the answer you’ve got on SO?


#3

thanks guys for taking time and suggesting solutions.