Julia’s ranges can act like letters
and LETTERS
:
julia> collect('a':'j')
10-element Array{Char,1}:
'a': ASCII/Unicode U+0061 (category Ll: Letter, lowercase)
'b': ASCII/Unicode U+0062 (category Ll: Letter, lowercase)
'c': ASCII/Unicode U+0063 (category Ll: Letter, lowercase)
'd': ASCII/Unicode U+0064 (category Ll: Letter, lowercase)
'e': ASCII/Unicode U+0065 (category Ll: Letter, lowercase)
'f': ASCII/Unicode U+0066 (category Ll: Letter, lowercase)
'g': ASCII/Unicode U+0067 (category Ll: Letter, lowercase)
'h': ASCII/Unicode U+0068 (category Ll: Letter, lowercase)
'i': ASCII/Unicode U+0069 (category Ll: Letter, lowercase)
'j': ASCII/Unicode U+006A (category Ll: Letter, lowercase)
julia> collect('A':'J')
10-element Array{Char,1}:
'A': ASCII/Unicode U+0041 (category Lu: Letter, uppercase)
'B': ASCII/Unicode U+0042 (category Lu: Letter, uppercase)
'C': ASCII/Unicode U+0043 (category Lu: Letter, uppercase)
'D': ASCII/Unicode U+0044 (category Lu: Letter, uppercase)
'E': ASCII/Unicode U+0045 (category Lu: Letter, uppercase)
'F': ASCII/Unicode U+0046 (category Lu: Letter, uppercase)
'G': ASCII/Unicode U+0047 (category Lu: Letter, uppercase)
'H': ASCII/Unicode U+0048 (category Lu: Letter, uppercase)
'I': ASCII/Unicode U+0049 (category Lu: Letter, uppercase)
'J': ASCII/Unicode U+004A (category Lu: Letter, uppercase)
There are many ways to combine these, one fun way is with broadcasting:
julia> lift(A) = reshape(A, 1, size(A)...)
lift (generic function with 1 method)
julia> lift(A, N) = reshape(A, (1 for _ ∈ 1:N)..., size(A)...)
lift (generic function with 2 methods)
julia> ('a':'c') .* lift('a':'c') .* '_' .* string.(lift(2001:2003, 2))
3×3×3 Array{String,3}:
[:, :, 1] =
"aa_2001" "ab_2001" "ac_2001"
"ba_2001" "bb_2001" "bc_2001"
"ca_2001" "cb_2001" "cc_2001"
[:, :, 2] =
"aa_2002" "ab_2002" "ac_2002"
"ba_2002" "bb_2002" "bc_2002"
"ca_2002" "cb_2002" "cc_2002"
[:, :, 3] =
"aa_2003" "ab_2003" "ac_2003"
"ba_2003" "bb_2003" "bc_2003"
"ca_2003" "cb_2003" "cc_2003"