Created
June 19, 2020 00:48
-
-
Save lunaspeed/676f072de712ddfc8d820e33af44bba3 to your computer and use it in GitHub Desktop.
go to functional
This file contains hidden or 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
func sum(list []int) int { | |
var t int | |
for _, i := range list { | |
t += i | |
} | |
return t | |
} | |
//只能加總數字? |
This file contains hidden or 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
type Appendable interface { | |
Append(Appendable) Appendable | |
} | |
func sum(list []Appendable) Appendable { | |
var t Appendable | |
for _, a := range list { | |
t = t.Append(a) | |
} | |
return t | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment