-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Description
Julia Version
versioninfo()Output
Julia Version 1.10.4
Commit 48d4fd4843 (2024-06-04 10:41 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: 8 × Intel(R) Core(TM) i5-9300H CPU @ 2.40GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-15.0.7 (ORCJIT, skylake)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)
Installation Details
- I downloaded the
Windows 64-bit installerfromhttps://julialang-s3.julialang.org/bin/winnt/x64/1.10/julia-1.10.4-win64.exe. - I used the default installation directory
C:\Users\%username%\AppData\Local\Programs\Julia-1.10.4. - I selected the following additional tasks:
- Create a Start Menu entry
- Add Julia to PATH
Icons:
- 🟩 Create a Desktop shortcut
- ✅ Create a Start Menu entry
Other:
- ✅ Add Julia to PATH
- I clicked the
Finishbutton.
Minimum Reproducible Example
- Create a file named
asd.jlwith the following content:
mutable struct Range
start::UInt32
finish::UInt32
end
function complement_range(input::Range, exclude::Range)::Vector{Range}
not_overlapping::Bool = input.start > exclude.finish || input.finish < exclude.start
if not_overlapping
return [Range(input.start, input.finish)]
end
result::Vector{Range} = []
if input.start < exclude.start
append!(result, [Range(input.start, exclude.start)])
end
if input.finish > exclude.finish
append!(result, [Range(exclude.finish, input.finish)])
end
return result
end
function test_complement_range()::Nothing
result = complement_range(Range(1, 10), Range(3, 7))
println("result::", typeof(result), ": ", result)
println("[Range(1, 3), Range(7, 10)]::",
typeof([Range(1, 3), Range(7, 10)]), ": ",
"[Range(1, 3), Range(7, 10)]"
)
println(
"complement_range(Range(1, 10), Range(3, 7)) == [Range(1, 3), Range(7, 10)]: ",
complement_range(Range(1, 10), Range(3, 7)) == [Range(1, 3), Range(7, 10)]
)
@assert [Range(1, 3), Range(7, 10)] == result
result = complement_range(Range(10, 20), Range(3, 7))
@assert [Range(10, 20)] == result
result = complement_range(Range(1, 3), Range(3, 7))
@assert [Range(1, 3)] == result
result = complement_range(Range(7, 10), Range(3, 7))
@assert [Range(7, 10)] == result
end
test_complement_range()- Run
include("asd.jl")to run the script in the Julia REPL
- or by executing
cmdin the file path bar of Windows Explorer and run the file withjulia asd.jl.
Expected Output
The expected output should be:
result::Vector{Range}: [Range(1, 3), Range(7, 10)]
[Range(1, 3), Range(7, 10)]::Vector{Range}: [Range(1, 3), Range(7, 10)]
complement_range(Range(1, 10), Range(3, 7)) == [Range(1, 3), Range(7, 10)]: trueActual Output
The actual output is:
result::Vector{Range}: Range[Range(0x00000001, 0x00000003), Range(0x00000007, 0x0000000a)]
[Range(1, 3), Range(7, 10)]::Vector{Range}: [Range(1, 3), Range(7, 10)]
complement_range(Range(1, 10), Range(3, 7)) == [Range(1, 3), Range(7, 10)]: false
ERROR: LoadError: AssertionError: [Range(1, 3), Range(7, 10)] == result
Stacktrace:
[1] test_complement_range()
@ Main C:\PROJECT_FOLDER\asd.jl:35
[2] top-level scope
@ C:\PROJECT_FOLDER\asd.jl:47
in expression starting at C:\PROJECT_FOLDER\asd.jl:47Metadata
Metadata
Assignees
Labels
No labels