20 lines
319 B
Go
20 lines
319 B
Go
package math
|
|
|
|
import "fmt"
|
|
|
|
type Pair[T SignedNumber] struct {
|
|
X, Y T
|
|
}
|
|
|
|
func NewPair[T SignedNumber](x, y T) Pair[T] {
|
|
return Pair[T]{X: x, Y: y}
|
|
}
|
|
|
|
func (p Pair[T]) Equal(other Pair[T]) bool {
|
|
return p.X == other.X && p.Y == other.Y
|
|
}
|
|
|
|
func (c Pair[T]) String() string {
|
|
return fmt.Sprintf("(%v,%v)", c.X, c.Y)
|
|
}
|