Created
July 20, 2020 02:53
-
-
Save haya14busa/51ee7fbc2db0eb6339f9fa4120e354b2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
func main() { | |
fmt.Println(g("al")) | |
fmt.Println(g()("al")) | |
fmt.Println(g()()("al")) | |
fmt.Println(g()()()("al")) | |
fmt.Println(g()()()()("al")) | |
fmt.Println(g()()()()()("al")) | |
fmt.Println(g()()()()()()("al")) | |
fmt.Println(g()("O")()("O")("al")("!")) | |
fmt.Println(g()()("gle")) | |
fmt.Println(g()("lang")) | |
} | |
type F func(...interface{}) F | |
func (f F) String() (out string) { | |
f(&out) | |
return | |
} | |
func g(al ...interface{}) F { | |
var f F | |
out := "g" | |
f = func(al ...interface{}) F { | |
if len(al) != 1 { | |
out += "o" | |
return f | |
} | |
switch a := al[0].(type) { | |
case string: | |
out += a | |
case *string: | |
*a = out | |
} | |
return f | |
} | |
return f(al...) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment