references are to such things as namespaces (≈JSON objects), GUI objects (WinForms), HTML Renderers, classes, instances, etc. Let's not worry about all those now.
Characters are denoted by single quotes 'a' is a scalar letter a.
APL doesn't really have strings, just lists (vectors in APL lingo) of characters.
In order to write a literal vector (=list) you just write the items next to each other.
E.g. in JSON that would imply an additional "layer" of nesting.
You can also mix data types: 'APL' 360 is a two-element vector. The first element is a three-element vector of chars, the second is a scalar number.
Btw, in APL a number is a number. APL converts between internal representations on the fly, so you never have to worry about such conversions. It even takes care of floating point imprecision for you!
@EriktheOutgolfer A simple array contains the data in plain form in memory. Any non-simple item is instead represented as a pointer to somewhere else in memory where that array is located. If that array isn't simple either, then it consists of pointers too. But that's all hidden from the user. It just works.
@EriktheOutgolfer Nope. You always (appear to) create a new array when modifying an array. However, internally, APL keeps a ref-count and points multiple names to the same memory location if possible.
The levels of nesting in APL lingo are called depth. A simple scalar has depth 0. A vector has depth 1. A vector of vectors has depth 2, etc. If the depth is uneven, then we report it as negative.
@EriktheOutgolfer Nope.
Oh, btw, negative numbers in APL are denoted by a high minus (like TI calculators).
You can have 1-element vectors, but you have to "create" them rather than write them. The prefix function , (comma) takes an array and makes it into a list. So ,6 is a one-element list.
Of course , doesn't do anything to 1 2 3 as it is already a list.
Now, don't get a chock! APL also has a concept of rank. The rank of an array is the number of dimensions in that array. A scalar has rank 0, a vector has rank 1.
However, we can also have a rank 2 array; a matrix, or table.
Note that rank ≠ depth.
So I can have a matrix where every element is a "string" (i.e. a vector). I can also have a vector of vectors of "strings".
Rank is always flush. Every row in a matrix must have the same number of columns. Every layer in a 3D block of data must have the same number of rows and columns.
Each APL implementation has a different max number of dimensions. Dyalog allows 15D arrays. If that isn't enough for you, you may be doing something not quite right.
@Mr.Xcoder Well, there I've seen documentation for systems allowing 255 dimensions and J, which is a dialect of APL (and the mother of Jelly) allows for an unlimited (except by memory) number of dimensions.
@J.Salle inside provinces inside countries inside the earth inside the solar system inside the galaxy inside the universe inside the world of parallel universes...
The infix function ⍴ (Greek letter "rho" for reshape) takes a list of dimension lengths as left argument and any data as right argument. It returns a new array with the specified dimensions, filled with the data.
(If there is too much data, the tail just doesn't get used. If there is too little, it gets recycled from the beginning.)
So we can create a 3-row, 4-column table with 3 4⍴'abcdefghijkl'
Most primitive APL functions have both a monadic (one argument) and a dyadic (two arguments) form. It is always clear from context which one is being applied, as all monadic functions are prefix, and all dyadic ones are infix.
So, we already addressed the dyadic ⍴ which was "reshape". The monadic ⍴ is "shape". So it reports back what the shape is.
@JohnDvorak "Mix", because it mixes elements together to form higher rank arrays. As opposed to "Split", ↓, which splits high-rank arrays into lists of lesser-rank arrays.
Monadic ⍴ always returns a vector. Monadic ≢ always returns a scalar. ≢ on a matrix returns the number of rows. ≢ on a 3D block returns the number of layers, etc.
We already saw how dyadic ⍴ can reshape things. Dyadic ↑ is take. In order to speak about its two arguments easier, we will give them names. The left argument we will call ⍺ as in the leftmost letter of the Greek alphabet, and the right argument we will call ⍵ as in the rightmost letter.
So ↑⍵ is monadic ↑ and ⍺↑⍵ is dyadic.↑.
⍺↑⍵ takes the ⍺ first major cells (!) from ⍵. E.g. 3↑3 1 4 1 5 is 3 1 4.
CMC: Any guesses (those that don't know) as to how we take from the back instead?
Definition and Rules
A golfy array is an array of integers, where each element is higher than or equal to the arithmetic mean of all the previous elements. Your task is to determine whether an array of positive integers given as input is golfy or not.
You do not need to handle the empty list.
...
@J.Salle If you want Dyalog APL for 2 OSs, then apply for two licences. I actually don't know if Karen will give you two serial numbers, but it doesn't matter what you enter into the serial number field upon install :-)
@EriktheOutgolfer It is a 5 "car" train. One "car" is not a function, but it is still a train because there is no data on the right.
I think we should continue with a few more array-manipulation primitives before we try tackling Uriel's solution.
The remaining array manipulation primitives are really simple. Monadic ∊enlists an array. It takes all the data, on all levels of depth and rank and creates a simple vector of depth 1.
It works for any-rank arrays, but they have to conform. You can even concatenate a vector to a matrix, and that will concatenate one element from the vector to each row of the matrix.
@EriktheOutgolfer pair? (and no, ; is special syntax in APL, not a function)