Тодор обнови решението на 23.10.2018 23:01 (преди 10 месеца)
+package main
+
+//import ("fmt")
+
+func Repeater(s, sep string) func(int) string {
+
+ repeatingSequence := s + sep
+
+ return func(repeatTimes int) string {
+ var result string
+ for repeatTimes > 0 {
+ result += repeatingSequence
+ repeatTimes--
+ }
+ return result[0 : len(result)-1]
+ }
+}
+
+func Generator(gen func(int) int, initial int) func() int {
+ var count *int = &initial
+ var flag bool
+ return func() int {
+ if !flag {
+ flag = true
+ return initial
+ } else {
+ *count = gen(*count)
+ return *count
+ }
+ }
+}
+
+func MapReducer(mapper func(int) int, reducer func(int, int) int, initial int) func(...int) int {
+ var counter *int = &initial
+ return func(nums ...int) int {
+ for _, num := range nums {
+ *counter = reducer(*counter, mapper(num))
+ }
+ return *counter
+ }
+}
+
+func main() {
+
+}