String splatting inside comprehensions

cnaak
Mon, 11 Mar 2024 14:59:39 +0000
General Usage

The following excerpt (taken from a julia-1.10.2 REPL) illustrates my question:

julia> src = ("Ab","Cd")
("Ab", "Cd")

julia> [ "Ab"..., "Cd"... ]
4-element Vector{Char}:
 'A': ASCII/Unicode U+0041 (category Lu: Letter, uppercase)
 'b': ASCII/Unicode U+0062 (category Ll: Letter, lowercase)
 'C': ASCII/Unicode U+0043 (category Lu: Letter, uppercase)
 'd': ASCII/Unicode U+0064 (category Ll: Letter, lowercase)

julia> [ i... for i in src ]
ERROR: syntax: "..." expression outside call around REPL[114]:1
Stacktrace:
 [1] top-level scope
   @ REPL[114]:1

Why can I manually splat Strings inside the Vector comprehension, but not so programatically? The error message indicates the lack of a call, but in the manual example, calls were lacking too.

How can I accomplish what was done manually, in a program?

12 posts - 6 participants