mirror of
https://github.com/vlang/v.git
synced 2025-09-15 23:42:28 +03:00
fmt: fix alignment of struct init fields (#22025)
This commit is contained in:
parent
99da5726db
commit
c51d30bf53
671 changed files with 18817 additions and 18787 deletions
|
@ -34,8 +34,8 @@ pub fn fraction(n i64, d i64) Fraction {
|
|||
return fraction(-n, -d)
|
||||
}
|
||||
return Fraction{
|
||||
n: n
|
||||
d: d
|
||||
n: n
|
||||
d: d
|
||||
is_reduced: math.gcd(n, d) == 1
|
||||
}
|
||||
}
|
||||
|
@ -62,8 +62,8 @@ fn general_addition_result(f1 Fraction, f2 Fraction, addition bool) Fraction {
|
|||
num1d2n := f1.d * f2.n
|
||||
n := if addition { num1n2d + num1d2n } else { num1n2d - num1d2n }
|
||||
return Fraction{
|
||||
n: n
|
||||
d: f1.d * f2.d
|
||||
n: n
|
||||
d: f1.d * f2.d
|
||||
is_reduced: true
|
||||
}
|
||||
}
|
||||
|
@ -75,8 +75,8 @@ fn general_addition_result(f1 Fraction, f2 Fraction, addition bool) Fraction {
|
|||
t := if addition { term1 + term2 } else { term1 - term2 }
|
||||
d2 := math.gcd(t, d1)
|
||||
return Fraction{
|
||||
n: t / d2
|
||||
d: f1den * (f2.d / d2)
|
||||
n: t / d2
|
||||
d: f1den * (f2.d / d2)
|
||||
is_reduced: true
|
||||
}
|
||||
}
|
||||
|
@ -106,16 +106,16 @@ fn general_multiplication_result(f1 Fraction, f2 Fraction, multiplication bool)
|
|||
d1 := math.gcd(f1.n, f2.d)
|
||||
d2 := math.gcd(f1.d, f2.n)
|
||||
return Fraction{
|
||||
n: (f1.n / d1) * (f2.n / d2)
|
||||
d: (f2.d / d1) * (f1.d / d2)
|
||||
n: (f1.n / d1) * (f2.n / d2)
|
||||
d: (f2.d / d1) * (f1.d / d2)
|
||||
is_reduced: true
|
||||
}
|
||||
} else {
|
||||
d1 := math.gcd(f1.n, f2.n)
|
||||
d2 := math.gcd(f1.d, f2.d)
|
||||
return Fraction{
|
||||
n: (f1.n / d1) * (f2.d / d2)
|
||||
d: (f2.n / d1) * (f1.d / d2)
|
||||
n: (f1.n / d1) * (f2.d / d2)
|
||||
d: (f2.n / d1) * (f1.d / d2)
|
||||
is_reduced: true
|
||||
}
|
||||
}
|
||||
|
@ -142,8 +142,8 @@ pub fn (f1 Fraction) / (f2 Fraction) Fraction {
|
|||
// Fraction negate method
|
||||
pub fn (f Fraction) negate() Fraction {
|
||||
return Fraction{
|
||||
n: -f.n
|
||||
d: f.d
|
||||
n: -f.n
|
||||
d: f.d
|
||||
is_reduced: f.is_reduced
|
||||
}
|
||||
}
|
||||
|
@ -154,8 +154,8 @@ pub fn (f Fraction) reciprocal() Fraction {
|
|||
panic('Denominator cannot be zero')
|
||||
}
|
||||
return Fraction{
|
||||
n: f.d
|
||||
d: f.n
|
||||
n: f.d
|
||||
d: f.n
|
||||
is_reduced: f.is_reduced
|
||||
}
|
||||
}
|
||||
|
@ -167,8 +167,8 @@ pub fn (f Fraction) reduce() Fraction {
|
|||
}
|
||||
cf := math.gcd(f.n, f.d)
|
||||
return Fraction{
|
||||
n: f.n / cf
|
||||
d: f.d / cf
|
||||
n: f.n / cf
|
||||
d: f.d / cf
|
||||
is_reduced: true
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue