-
Notifications
You must be signed in to change notification settings - Fork 15
Converting collections to InlineString #4
Copy link
Copy link
Closed
Description
Currently the following is challenging:
julia> x = ["1"^i for i in 1:20]
20-element Vector{String}:
"1"
"11"
"111"
"1111"
"11111"
"111111"
"1111111"
"11111111"
"111111111"
"1111111111"
"11111111111"
"111111111111"
"1111111111111"
"11111111111111"
"111111111111111"
"1111111111111111"
"11111111111111111"
"111111111111111111"
"1111111111111111111"
"11111111111111111111"
julia> y = InlineString.(x)
20-element Vector{InlineString}:
"1"
"11"
"111"
"1111"
"11111"
"111111"
"1111111"
"11111111"
"111111111"
"1111111111"
"11111111111"
"111111111111"
"1111111111111"
"11111111111111"
"111111111111111"
"1111111111111111"
"11111111111111111"
"111111111111111111"
"1111111111111111111"
"11111111111111111111"
julia> typeof.(y)
20-element Vector{DataType}:
InlineString1
InlineString3
InlineString3
InlineString7
InlineString7
InlineString7
InlineString7
InlineString15
InlineString15
InlineString15
InlineString15
InlineString15
InlineString15
InlineString15
InlineString15
InlineString31
InlineString31
InlineString31
InlineString31
InlineString31
Ideally we should provide a convenient way to automatically get a correct "widest" type for the container. I am not sure how to best handle it (maybe add a function that for a given collection of strings returns the InlineString* type that can store them all?).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels