Skip to content
Snippets Groups Projects
Commit be105648 authored by bg33novu's avatar bg33novu
Browse files

right now I hate Julia

parent 08988b99
No related branches found
No related tags found
No related merge requests found
triangle = [2, 3, 4]
triangle2 = [2, 2, 2]
triangle2_line = [2 2 2]
triangle = triangle .+ 1
triangle .+ triangle2
triangle .* triangle2
triangle2_line * triangle # mathematical vector multiplication
triangle2 * triangle
triangle2_line .* triangle
triangle_bis = triangle
triangle[1] = 0
triangle_bis
a = 5
b = a
a = 0
b
function is_Right(lengths)
for i=1:length(lengths)
lengths[i] = lengths[i]^2
end
println(lengths)
sort!(lengths)
# squares = sort(squares)
println(lengths)
return(lengths[3] == lengths[1] + lengths[2])
end
triangle = [5, 3, 4]
println(is_Right(triangle))
println(triangle)
function is_Right2(lengths)
lengths = [x^2 for x in lengths]
println(lengths)
sort!(lengths)
# squares = sort(squares)
println(lengths)
return(lengths[3] == lengths[1] + lengths[2])
end
triangle = [5, 3, 4]
println(is_Right!(triangle))
println(triangle)
function temp(a)
a = [4,5,6]
end
function temp1(a)
a .= [4,5,6]
end
triangle = [2, 3, 4]
temp(triangle)
triangle
temp1(triangle)
function is_Right2Bis(lengths)
lengths .= [x^2 for x in lengths]
println(lengths)
sort!(lengths)
# squares = sort(squares)
println(lengths)
return(lengths[3] == lengths[1] + lengths[2])
end
triangle = [5, 3, 4]
println(is_Right!(triangle))
println(triangle)
function recursive_factorial(n)
if n == 1
return(1)
else
return(n*recursive_factorial(n-1))
end
end
recursive_factorial(12)
function loop_factorial(n)
res = 1
for i in 1:n
res = res*i
end
return(res)
end
loop_factorial(12)
@elapsed recursive_factorial(4200)
@elapsed loop_factorial(4200)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment