I just started learning APL a couple of weeks ago, so this may sound like a beginner's question.
Let B be a string, which in terms of APL can be either a scaler or a vector. If it is a scalar, ā“B returns zero, not the string length, as I want.
Bā'QR' ā“B ā returns 2 Bā'Q' ā“B ā returns null
I discovered one way:
ā“1ā'X',B ā concatenating X and then removing it returns a value of 1
This works, but it seems a bit hockey, so I wonder if there is a more standard way to find the length of a string.
Is it just me or does it seem a little inconsistent? The textbook that I read said that it is considered scalar as a point, similar to how it is done in vector algebra. But how is it that concatenating a scalar to a scalar makes a vector, but dropping a scalar from a vector never leads to a scalar?
I really like the APL, so this question does not mean criticism. My question is: what is the best way to find the length of a string? And, if someone can shed some light on this seeming inconsistency, it will be appreciated.
source share