Consider the lone factorial problem: Every array programmer will do some kind of the product of, one plus array of all ints up to x
apl: ×/⍳X
q: prd 1+til x
j: */1+i.x
k: */1+!x
Notice how similar they are?Now, how do you solve this problem in Fortran? In Python? In R? In Matlab? What's the first tool in your toolbox? Is it to iterate over the values?
FUNCTION FACT(N)
INTEGER N,I,FACT
FACT=1
DO 10 I=1,N
10 FACT=FACT*I
END
def fact(n):
result = 1
for i in range(1, n+1):
result *= i
return result
function b=fact(a)
b=1;
for i=1:a
b=b*i;
end
function fact = iter_fact(n)
fact = 1;
for i = 2:n
fact = fact * i;
endfor
endfunction
fact <- function(n) {
f = 1
for (i in 2:n) f <- f * i
f
}
If the native programmer's first impulse looks something like that, then it's not an array language because the programmer isn't thinking in terms of arrays.