diff options
author | Dimitri Sokolyuk <demon@dim13.org> | 2015-05-06 23:40:20 +0200 |
---|---|---|
committer | Dimitri Sokolyuk <demon@dim13.org> | 2015-05-06 23:40:20 +0200 |
commit | b689698a7853bf8ce56a2d028e3ae47672ea090e (patch) | |
tree | de6980ce2962aef2bfc18d2441f5cd89851a168f /units.go | |
parent | 69668aa61de642ea275e6e2ace85f7b921480603 (diff) |
add scan functions
Diffstat (limited to 'units.go')
-rw-r--r-- | units.go | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -16,6 +16,11 @@ func (u Unit) String() string { return fmt.Sprintf("%.2f", u) } +func ScanUnit(s string) (u Unit) { + fmt.Sscanf(s, "%v", &u) + return +} + type Point struct { X, Y Unit } @@ -24,6 +29,11 @@ func (p Point) String() string { return fmt.Sprintf("%v,%v", p.X, p.Y) } +func ScanPoint(s string) (p Point) { + fmt.Sscanf(s, "%v,%v", &p.X, &p.Y) + return +} + type Triple struct { U, V, W Unit } @@ -32,6 +42,11 @@ func (t Triple) String() string { return fmt.Sprintf("%v,%v,%v", t.U, t.V, t.W) } +func ScanTriple(s string) (t Triple) { + fmt.Sscanf(s, "%v,%v,%v", &t.U, &t.V, &t.W) + return +} + type Polar struct { R, Theta Unit } |