aboutsummaryrefslogtreecommitdiff
path: root/challenge-253/barroff/julia/ch-1.jl
blob: 7f8a4c3133e4b14008b1fc8c275505100796b914 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/env julia

using Test: @test, @testset

function split_strings(separator::Char, words::Vector{T}) where {T<:AbstractString}
    return collect(
        Iterators.flatten([
            filter(x -> lastindex(x) > 0, x) for x in map(x -> split(x, separator), words)
        ]),
    )
end

@testset "split strings" begin
    @test split_strings('.', ["one.two.three", "four.five", "six"]) ==
          ["one", "two", "three", "four", "five", "six"]
    @test split_strings('$', [raw"$perl$$", raw"$$raku$"]) == ["perl", "raku"]
end