package main import ( "fmt" "math" ) type S string // string type I int64 // int type F float64 // float type C complex128 // complex type A interface{} // any type Monad func(complex128) complex128 type Dyad func(complex128, complex128) 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, float64(f)) } func (c C) String() string { return fmt.Sprint(F(real(c)), "J", F(imag(c))) } func IsInt(c complex128) bool { return imag(c) == 0 && math.Trunc(real(c)) == real(c) } func IsFloat(c complex128) bool { return imag(c) == 0 && math.Trunc(real(c)) != real(c) } func IsComplex(c complex128) bool { return imag(c) != 0 }