map is sometimes more convinient instead of for. The code

can be reformed using map

for loop is sometimes slow because the dot evaluation inside is evaluated for each loop. Thus the following code is more efficient.