4 ms·
No - An array is a data structure that stores pre-calculated values in memory, whereas a function is executable logic that computes a result only when it is cal
by dankwizard 9mo ago
No - An array is a data structure that stores pre-calculated values in memory, whereas a function is executable logic that computes a result only when it is called.
- wvenable 9mo agoCorrect. But indexing into an array is logic that computes a result when it is called.
- adastra22 9mo agoThere are two opposing philosophical viewpoints here. Some view mathematics as a model for understanding the real world. Some see the real world as instantiation of mathematics. Is an array a function? From one perspective, the array satisfies the abstract requirements we use to define the word "function." From the other perspective, arrays (contiguous memory) exist and are real things, and functions (programs) exist and are something else.
- wvenable 9mo agoAn array isn't a function -- indexing an array could be a function. But an array is a data structure. An array doesn't satisfy the requirements to be a function -- people are just confusing an array with array indexing.
- adastra22 9mo agoIn the mathematical sense a function is something that maps inputs to outputs. That’s also what an array is. But this whole thing is uninteresting because it is ultimately just a disagreement about definitions.
- deleted 9mo ago[deleted]
- emmelaich 9mo agoNot a semantic difference, just a performance difference ... and a function can cache for the same performance anyway.