You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What would it take to add to Hugo’s templates the ability to calculate square roots?
We already have basic arithmetic (add, mul, etc.) and some other Go functions (math.Floor, math.Round, etc.), but not math.Sqrt.
Why would I want to calculate square roots? Because I’m trying to display a group of differently-shaped images so that they all take up the same area on the screen. See MathCentral for the formula.
So I’d like to be able to use math.Sqrt in my shortcode.
Meanwhile, I'll have a look at the code and see if I can come up with a pull request for such a feature.
The text was updated successfully, but these errors were encountered:
See MathCentral for the formula.
I'll have a look at the code and see if I can come up with a pull request for such a feature.
Luckily we don't have to implement the formula ourselves. 🙂 Go's math.Sqrt() function (here) provides the capability we need. You can use that function to implement the square root behaviour in Hugo.
It looks like Hugo defines the math functions in the math.go file. That's a good place to start.
What would it take to add to Hugo’s templates the ability to calculate square roots?
We already have basic arithmetic (
add
,mul
, etc.) and some other Go functions (math.Floor
,math.Round
, etc.), but notmath.Sqrt
.Why would I want to calculate square roots? Because I’m trying to display a group of differently-shaped images so that they all take up the same area on the screen. See MathCentral for the formula.
So I’d like to be able to use
math.Sqrt
in my shortcode.Meanwhile, I'll have a look at the code and see if I can come up with a pull request for such a feature.
The text was updated successfully, but these errors were encountered: