A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
19
Task/Man-or-boy-test/Go/man-or-boy-test-1.go
Normal file
19
Task/Man-or-boy-test/Go/man-or-boy-test-1.go
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
package main
|
||||
import "fmt"
|
||||
|
||||
func a(k int, x1, x2, x3, x4, x5 func() int) int {
|
||||
var b func() int
|
||||
b = func() int {
|
||||
k--
|
||||
return a(k, b, x1, x2, x3, x4)
|
||||
}
|
||||
if k <= 0 {
|
||||
return x4() + x5()
|
||||
}
|
||||
return b()
|
||||
}
|
||||
|
||||
func main() {
|
||||
x := func(i int) func() int { return func() int { return i } }
|
||||
fmt.Println(a(10, x(1), x(-1), x(-1), x(1), x(0)))
|
||||
}
|
||||
24
Task/Man-or-boy-test/Go/man-or-boy-test-2.go
Normal file
24
Task/Man-or-boy-test/Go/man-or-boy-test-2.go
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func A(k int, x1, x2, x3, x4, x5 func() int) (a int) {
|
||||
var B func() int
|
||||
B = func() (b int) {
|
||||
k--
|
||||
a = A(k, B, x1, x2, x3, x4)
|
||||
b = a
|
||||
return
|
||||
}
|
||||
if k <= 0 {
|
||||
a = x4() + x5()
|
||||
} else {
|
||||
B()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func main() {
|
||||
K := func(x int) func() int { return func() int { return x } }
|
||||
fmt.Println(A(10, K(1), K(-1), K(-1), K(1), K(0)))
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue