June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
14
Task/Exceptions/Julia/exceptions.julia
Normal file
14
Task/Exceptions/Julia/exceptions.julia
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
function extendedsqrt(x)
|
||||
try sqrt(x)
|
||||
catch
|
||||
if x isa Number
|
||||
sqrt(complex(x, 0))
|
||||
else
|
||||
throw(DomainError())
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@show extendedsqrt(1) # 1
|
||||
@show extendedsqrt(-1) # 0.0 + 1.0im
|
||||
@show extendedsqrt('x') # ERROR: DomainError
|
||||
Loading…
Add table
Add a link
Reference in a new issue