I’m trying write a code as
make_random_string(n::Int)::String = (prod ∘ map)(Char, rand(65:90, n))
function outer_string(n::Int)::Tuple{String, String}
orig_str = make_random_string(n)
result_io = IOBuffer()
run(pipeline(`echo $orig_str`; stdout=result_io))
result_str = (String ∘ take!)(result_io)
return orig_str, result_str[begin:end-1]
end
function main()
n_list = rand(10:100, 100)
pushfirst!(n_list, 10^6)
Threads.@threads for n ∈ n_list
# for n ∈ n_list
orig_str, rslt_str = outer_string(n)
if orig_str != rslt_str
@show n, orig_str, rslt_str
end
end
end
main()
Then, run julia -t 8 main.jl
, it shows that
(n, orig_str, rslt_str) = (47, "WQRHRDILRKIVDDKOYNQWBUBBZJCCCMIGJPOEFASLMRPGQTN", "")
(n, orig_str, rslt_str) = (80, "AMFSFDGKTTNNGNHYXSOKYKVTIAPIMSIJYALREWIIKOFPFIQXPIGHOFDYJFIHGKLDLGHFOHQMHVGGWTFU", "")
(n, orig_str, rslt_str) = (29, "OOHSVEQJSPSVTWIVHWKJASCRANMSK", "")
(n, orig_str, rslt_str) = (49, "DVQXHVZDKCGCOAJGCDMZDISLMGBISLTJGLCNUUWTXSHHCQKYH", "")
(n, orig_str, rslt_str) = (59, "OSPSJJESVNZQVMHPCQHKOUNBTRIMTPUSNFNDCBPTGOVETBCKIRHGVLDFPFP", "")
(n, orig_str, rslt_str) = (45, "JHCWOYROYBOYYDDUOXZGXAKNFVFPZDCQMRBPNXMUAFKND", "")
(n, orig_str, rslt_str) = (23, "EAUVYYGFTJHHZLLQREEIZDZ", "")
Actually, julia main.jl
returns no logs.
It seems that there are some broken running.
Why and how to correct the codes?