4 ms·
I think they are forgetting that a lot of languages take que's from old math textbooks where you would see function definitions written as "f(x) = nx + b" or "y
by Stranger43 9y ago
I think they are forgetting that a lot of languages take que's from old math textbooks where you would see function definitions written as "f(x) = nx + b" or "y = nx + b" and constant assignment with a "c = <number>" notation.
if you want to calculate the output of a function into a data table(which is what early computers were often doing) iterating a variable x over a f(x) = xn + b(with n and b being fixed constants) is exactly how you would do it on paper so it's probably a case of computers emulating applied math rather then simply being pure theory machines.
- rocqua 9y agoThis works for initialization, but not for reassignment. Most notably, it is absurd for statements like x = x + 1. Meanwhile, such self-referential updates are very common in imperative programming, so anyone designing the language would come across this.
- vlasev 9y agoYou have something similar in mathematics. Recurrence relations. Since we are dealing with a sort of time difference inside a computer, something like "x = x + 1" can be interpreted as "the value of x at the next time unit is the value of x at the previous time unit plus one". That is "x[n+1] = x[n] + 1" and this is a recurrence relation. My guess is that early programmers were deeply aware of this time difference, so "x = x + 1" made perfect sense.
- rocqua 9y agoThe way these recurrence relations are taught at university is to distinguish the new value from the old value by using a ' pronounced prime. Here, you would write x' = x + 1 to give the recurrence relation x[n+1] = x[n] + 1. Or, more generally x' = f(x) for x[n+1] = f(x[n]). The reason for this is because in mathematics x = x + 1 is absurd (ignoring modulo arithmetic).
- Izkata 9y agoIn highschool, we used numeric subscripts for that. Ticks(apostrophes) were kept for derivatives.
- jcranberry 9y agoWhat you have there is a sequence. Recursively defined or not, taking the indices out of a sequence takes away the only thing that makes it a sequence (the mapping from the natural numbers) and would be a horrible abuse of notation. I think language designers were certainly consciously aware that they were designing something well defined, and chose to use this kind of syntax because its simpler, rather than an implicit mapping to the natural numbers via something like CPU cycles.
- mpweiher 9y ago> What you have there is a sequence. See Lucid[1] >takes away the only thing that makes it a sequence Unless everything is a sequence[1] [1] http://www.cse.unsw.edu.au/~plaice/archive/WWW/1985/B-AP85-LucidDataflow.pdf http://www.cse.unsw.edu.au/~plaice/archive/WWW/1985/B-AP85-L...
- rocqua 9y agoThere is a really simple mapping between recurrent sequences and functions. Simply, given a function $f: A -> A$ that is, a function that outputs from the set it gets input from. We then have the sequence $x_n+1 = f(x_n)$. Often, when dealing with incremental algorithms, the notation x' = f(x) is used. Here x' (pronounced x prime) stands for "the next value of x". It's a nice balance between the correctness of using indices and the conciseness of leaving them out. Going to a higher level, the sequence x' = f(x) is essentially trying to find a fixed point of the function f. To look at this in an actual for or while loop, you need to consider the stopping condition of the loop as part of the function.
- deleted 9y ago[deleted]
- kps 9y agoThat is, explicitly, the origin of ‘=’ for assignment in Fortran. The section describing assignment is titled ‘Arithmetic Formulas’: A. An arithmetic formula is a variable (subscripted, or not), followed by an equals sign, followed by an expression. B. It should be noted that the equals sign in an arithmetic formula has the significance of “replace”. In effect, therefore, the meaning of an arithmetic formula is as follows: Evaluate the expression on the right and substitute this value as the value of the variable on the left.
- jrochkind1 9y ago_old_ math textbooks? Have they changed this in new ones?
- delaaxe 9y agoSaying something is old implies that it has been the case for a long time, not that it has necessarily changed recently.
- nitwit005 9y agoYes, I remember noticing how similar basic was to what you'd see in a math textbook. You'd expect to see a variable defined like "let x equal (whatever)", and basic just mimicked that: "LET X = 9".