aboutsummaryrefslogtreecommitdiff
path: root/format.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-03-23 12:30:32 +0100
committerDimitri Sokolyuk <demon@dim13.org>2015-03-23 12:30:32 +0100
commit73a4e6134c0ae131b68dd946bd9f585dd21b97ee (patch)
tree8086429940c1d2bd034e38635a6972c58696c69d /format.go
parent19f1a104f5e4e3b04914183c76a2dc70ba03d8d1 (diff)
Add output formatter
Diffstat (limited to 'format.go')
-rw-r--r--format.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/format.go b/format.go
new file mode 100644
index 0000000..5a554eb
--- /dev/null
+++ b/format.go
@@ -0,0 +1,34 @@
+package main
+
+import "fmt"
+
+type S string
+type I int64
+type F float64
+type C complex128
+
+func (s S) String() string {
+ return string(s)
+}
+
+func (i I) String() string {
+ pre := ""
+ if i < 0 {
+ pre = "¯"
+ i = -i
+ }
+ return fmt.Sprint(pre, int64(i))
+}
+
+func (f F) String() string {
+ pre := ""
+ if f < 0 {
+ pre = "¯"
+ f = -f
+ }
+ return fmt.Sprint(pre, int64(f))
+}
+
+func (c C) String() string {
+ return fmt.Sprint(F(real(c)), "J", F(imag(c)))
+}