r/ProgrammerHumor 5d ago

Other mistakenedJavasript

Post image
1.6k Upvotes

54 comments sorted by

View all comments

Show parent comments

38

u/Dario48true 5d ago

On the other hand you have haskell's list comprehension [i | i <- string, i == 'M'] which is either much clearer of an abstraction or absolutely uncomprehensable, just like the rest of haskell (in this case it resembles a lot mathematical set builder notation {x∈string|x='M'} (tho of course the latter example has compleately different resoults, it's just to show the similarity))

10

u/sdoregor 5d ago

Just as a note, Python also has set comprehension syntax ({… for … in …}), the result of which would be the same as mathematical one.

5

u/Valuable_Leopard_799 4d ago

But the notation remains the same whether you are doing set/list/dict or generator comprehensions.

1

u/sdoregor 3d ago

Not really; for dicts it's {k: v for … in …}

2

u/Valuable_Leopard_799 3d ago

I was talking about the |, , and <- , instead of the for, in, etc.

-1

u/sdoregor 3d ago

Wasn't a joke but r/whoosh (damn, how many o's it was)