I know you can get a character vector of all numbers with ∊⍕¨⍳10
, but is there a platform independent idiom for getting a vector of all alphabetical characters, aside from manually typing 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
? I know that I can do ⎕AV[(⍳26)+(⎕AV⍳'a')-1]
to get all lowercase characters (and uppercase by changing the 'a'
to 'A'
) in Dyalog APL, but I presume the system variable ⎕AV
isn't available in other environments.
Not really.
In Dyalog APL, what I generally do is use ⎕A
for the uppercase characters and ⎕UCS 96+⍳26
for the lowercase characters. (And ⎕A,⎕UCS 96+⍳26
for the whole alphabet.)
⎕AV
is usually present, but its contents are not standard. (For example, NARS2000's ⎕AV
is different from Dyalog's.) By the way, in Dyalog ⎕AV
is considered deprecated in favour of ⎕UCS
. Any APL that implements ⎕UCS
will do it the same way, because Unicode is a set standard.
If you want a guaranteed implementation-independent, readable way to define the alphabet I would indeed recommend to just store abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
in your workspace.
However, I would not recommend trying to write implementation-independent APL code to begin with. APL dialects are rather divergent, so this is decidedly nontrivial (if possible at all for complex code), and will be difficult to maintain.