mirror of
https://gitlab.rlp.net/mobitar/julia_course.git
synced 2024-11-23 13:31:36 +00:00
Fix FourVector task
This commit is contained in:
parent
49096484ae
commit
c30cb07b53
1 changed files with 9 additions and 7 deletions
|
@ -1,5 +1,5 @@
|
|||
### A Pluto.jl notebook ###
|
||||
# v0.18.4
|
||||
# v0.19.0
|
||||
|
||||
using Markdown
|
||||
using InteractiveUtils
|
||||
|
@ -53,7 +53,7 @@ z - z'
|
|||
|
||||
$v * u = ct * ct' - x * x' - y * y' - z * z'$
|
||||
|
||||
$|v|^2 = ct^2 - x^2 - y^2 - z^2$
|
||||
$|v|^2 = (ct)^2 - x^2 - y^2 - z^2$
|
||||
|
||||
You should implement $|v|^2$ as a function called `length_squared`.
|
||||
"""
|
||||
|
@ -66,20 +66,22 @@ begin
|
|||
|
||||
# To override a predefined function of a package, the function has to be imported
|
||||
# In this case, the functions are from the package `Base` which has Julia's builtin functions
|
||||
import Base: +, -, *, ^
|
||||
import Base: +, -, *, ==
|
||||
|
||||
(+)(v::FourVector, u::FourVector) = FourVector(
|
||||
+(v::FourVector, u::FourVector) = FourVector(
|
||||
v.ct + u.ct,
|
||||
v.x + u.x,
|
||||
v.y + u.y,
|
||||
v.z + u.z
|
||||
)
|
||||
|
||||
#(-)(v::FourVector) = ?
|
||||
# -(v::FourVector) = ?
|
||||
|
||||
#(-)(v::FourVector, u::FourVector) = ?
|
||||
# -(v::FourVector, u::FourVector) = ?
|
||||
|
||||
#(*)(v::FourVector, u::FourVector) = ?
|
||||
# *(v::FourVector, u::FourVector) = ?
|
||||
|
||||
# ==(v::FourVector, u::FourVector) = ?
|
||||
end
|
||||
|
||||
# ╔═╡ 4b8da4d9-c880-405e-859e-81f5884d29bf
|
||||
|
|
Loading…
Reference in a new issue