The audacity to do such a thing…

You are viewing a single thread.
View all comments
121 points

The answer is a map or dictionary.

permalink
report
reply
32 points
*

Or sometimes even just an array. The first time I thought I wanted to do this was 2003 and I was writing a perl script, and I was trying to loop through some sort of array, and write the outputs of some calculations to $val0 $val1 and so on, and I was neck deep into some horrible dark constructs like ${"val" . $i} before I actually realized that I really just wanted an array, you know, like the one I was already using.

It took me forever to understand map (the metafunction).

permalink
report
parent
reply
13 points

It depends. If the variable names are arbitrary, then a map is best. If the variable names are just x_1, x_2, x_3, …, x_n, then a list or dynamic array would be more natural. If n is constant, then a vector or static array is even better.

permalink
report
parent
reply
10 points

I’ve just figured out linked lists and I want to call that the solution ¯_(ツ)_/¯

permalink
report
parent
reply
20 points

When you get a new hammer…

permalink
report
parent
reply
9 points

I mean, I wouldn’t recommend it, but seems like a data structure that could work.

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