this post was submitted on 01 Oct 2023
476 points (96.7% liked)

Programmer Humor

35022 readers
59 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 

The audacity to do such a thing…

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 34 points 2 years ago (9 children)

A common problem (before learning it is impossible/fraught with danger) is categorisation, like sorting of strings.

Say you have a text, and need to count words of different lengths.

One intuitive approach is to pass through it once and add each word to a list for the corresponding length, as well as making lists as needed. No 7 letter words, no 7-letter-word-list, even though there are longer words.

As humans we're good at sorting things into an unknown number of categories, and we have to unlearn that for programming

[–] [email protected] 30 points 2 years ago (6 children)

Would one not just use a dict/hashmap with int keys labelling lengths and the list of strings as the values?

[–] [email protected] 5 points 2 years ago (3 children)
[–] avonarret1 3 points 2 years ago

Because those are limited to Python? 😜

load more comments (2 replies)
load more comments (4 replies)
load more comments (6 replies)