The audacity to do such a thing…

You are viewing a single thread.
View all comments View context
34 points

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

permalink
report
parent
reply
30 points

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

permalink
report
parent
reply
29 points
*

A programmer might, as trained/conditioned by the limits of programming languages.

A human would intuitively not, these are meaningless and/or convoluted concepts to the untrained human.

permalink
report
parent
reply
16 points

I like the implication that programmers aren’t humans, but a sort of alien being naturally apt at algorithmic thinking, while puny humans are an irrational species that needs to undergo training from the mighty race of programmers if they hope to get into the field brought us here by the aliens

permalink
report
parent
reply
5 points

Found the Python guy.

permalink
report
parent
reply
7 points

‘List’ is the correct abstract term for any data structure that holds a given number of values in an order, regardless of the implementation. So Python’s List, or C++'s Array or Vector, or a Linked List are all considered lists in the abstract sense.

permalink
report
parent
reply
6 points

I did use ‘list’ and forgot it is called an ‘array’ or ‘vector’ in other languages. So sure, close enough :-)

permalink
report
parent
reply
3 points

Because those are limited to Python? 😜

permalink
report
parent
reply
6 points

This makes a ton of sense and I think you probably solved this mystery for me.

“Oh I need to iterate over something, and keep track of new information as I do it, therefore I should be able to create ‘dynamic variables’ as I progress.”

permalink
report
parent
reply
0 points

Yep, what you failed to realise at the time is you’ve just invented a dynamic data structure like a list or a dictionary.

permalink
report
parent
reply

Programmer Humor

!programmerhumor@lemmy.ml

Create post

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

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.

Community stats

  • 3.7K

    Monthly active users

  • 1.5K

    Posts

  • 35K

    Comments