How dare you ask this? Was it just to get into a programming memes page?

https://suppo.fi/post/362982

How dare you ask this? Was it just to get into a programming memes page? - suppo.fi

The audacity to do such a thing…

I distinctly remember asking this question during a 100 level programming class but I just can not remember why I’d ever want to do this?

What problem could I have possibly have been trying to solve where this would seem like the answer.

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

Would one not just use a dict/hashmap with int keys labelling lengths and the list of strings as the values?
Found the Python guy.
Because those are limited to Python? 😜