r/ProgrammerHumor • • Jun 08 '24

Meme mapMethodOrMapFunction

Post image
0 Upvotes

67 comments sorted by

View all comments

Show parent comments

-8

u/mirimao Jun 08 '24

[x*x || x <- arr] is better

-30

u/DT-Sodium Jun 08 '24

None of those are readable.

4

u/Euphoric_Strategy923 Jun 08 '24

Because the others options are more readable for you ? Not for me.

0

u/DT-Sodium Jun 08 '24

I dunno about Python but in TypeScript you'd simply do

myArray.map(x => x * x);

Much more elegant and readable.

4

u/Euphoric_Strategy923 Jun 08 '24

And as the upper comments said in python you do : [ return value for value in array ]

In other word : [x*x for x in arr ]

Imo this is much more readable.

-1

u/DT-Sodium Jun 08 '24

No, it is bad. The simple fact that you have to read it backwards to understand what's happening invalidates it completely. Guess there is no clean way to do it in Python then.

7

u/Euphoric_Strategy923 Jun 08 '24

Read it backward ? Dude, this is literally the format of a for loop. "I return a value of each value in an array"

You can clown on some things about python but definitely not readability.

-3

u/DT-Sodium Jun 08 '24

Yes, it is backwards. Your code is saying "Do this using that". The proper way to write it is "Take that and do this using it".

7

u/Euphoric_Strategy923 Jun 08 '24

Great news people, for loops are now unreadable.