From a1325f830b2c3004c7fe6249efa2e06f875dbf75 Mon Sep 17 00:00:00 2001 From: Marek Kaluba Date: Wed, 14 Feb 2024 14:20:31 +0100 Subject: [PATCH] simplify star(w::Word) in tests --- test/test_example_words.jl | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/test/test_example_words.jl b/test/test_example_words.jl index fc327ce..276a20e 100644 --- a/test/test_example_words.jl +++ b/test/test_example_words.jl @@ -29,18 +29,13 @@ function Base.:*(w::Word, z::Word) end function StarAlgebras.star(w::Word) - newletters = similar(w.letters) - # star(:a) = :b # star(:b) = :a # star(:c) = :c star_d = Dict(1 => 2, 2 => 1) - for (i, l) in enumerate(Iterators.reverse(w.letters)) - k = haskey(star_d, l) ? star_d[l] : l - newletters[i] = k - end + newletters = [get(star_d, l, l) for l in Iterators.reverse(w.letters)] return Word(w.alphabet, newletters) end