top | item 46700701

(no title)

dankwizard | 1 month 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.

discuss

order

emmelaich|1 month ago

Not a semantic difference, just a performance difference ... and a function can cache for the same performance anyway.

wvenable|1 month ago

Correct. But indexing into an array is logic that computes a result when it is called.

adastra22|1 month ago

There 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.