Skip to content

Converting collections to InlineString #4

@bkamins

Description

@bkamins

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?).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions