Skip to content

Commit

Permalink
Add infix where instructive
Browse files Browse the repository at this point in the history
  • Loading branch information
propensive committed Jan 26, 2024
1 parent f2e90fb commit 93d8663
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core/quantity.scala
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ object QuantitativeMacros:
def empty: Boolean = map.values.all(_.power == 0)

@targetName("multiply")
def *(that: UnitsMap): UnitsMap = new UnitsMap(
infix def * (that: UnitsMap): UnitsMap = new UnitsMap(
(dimensions ++ that.dimensions).to(Set).to(List).map: dim =>
val dimUnit = unit(dim).orElse(that.unit(dim)).get
dim -> UnitPower(dimUnit, (unitPower(dim) + that.unitPower(dim)))
.to(Map).filter(_(1).power != 0)
)

@targetName("divide")
def /(that: UnitsMap): UnitsMap = new UnitsMap(
infix def / (that: UnitsMap): UnitsMap = new UnitsMap(
(dimensions ++ that.dimensions).to(Set).to(List).map: dim =>
val dimUnit = unit(dim).orElse(that.unit(dim)).get
dim -> UnitPower(dimUnit, (unitPower(dim) - that.unitPower(dim)))
Expand Down

0 comments on commit 93d8663

Please sign in to comment.