aboutsummaryrefslogtreecommitdiff
path: root/format.go
blob: b1a939c2595252b10e7471d7ee3657972d4ffc8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package main

import "fmt"

type S string       // string
type I int64        // int
type F float64      // float
type C complex128   // complex
type A interface{}  // any
type M func(A) A    // monad
type D func(A, A) A // dyad

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, float64(f))
}

func (c C) String() string {
	return fmt.Sprint(F(real(c)), "J", F(imag(c)))
}