J's #: (base)
can be used to compute the offset of an array element as it would appear in
memory. Why so? x #: y is +/w*y, where w is formed as */\.}.x,1—w is precisely the strides of an array with dimensions x.
One motivation for Apple was demonstrating typed array programming. Shape types are rich; we can use types as witnesses as in QuickCheck, generating test cases that are shape-correct.
Apple, being a JIT compiler with shape types, is able to do a number of optimizations based on inferred dimension (and rank). Rank is almost always known in practice, so such optimizations are pertinent.
I previously wrote about typing elliptic fourier series; my Apple compiler is now capable of computing the offsets and also the relevant coefficients.
To compute a 7-day moving average:
next