Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -7,13 +7,13 @@ type FuncFunc func(Func) Func
|
|||
type RecursiveFunc func (RecursiveFunc) Func
|
||||
|
||||
func main() {
|
||||
fac := fix(almost_fac)
|
||||
fib := fix(almost_fib)
|
||||
fac := Y(almost_fac)
|
||||
fib := Y(almost_fib)
|
||||
fmt.Println("fac(10) = ", fac(10))
|
||||
fmt.Println("fib(10) = ", fib(10))
|
||||
}
|
||||
|
||||
func fix(f FuncFunc) Func {
|
||||
func Y(f FuncFunc) Func {
|
||||
g := func(r RecursiveFunc) Func {
|
||||
return f(func(x int) int {
|
||||
return r(r)(x)
|
||||
5
Task/Y-combinator/Go/y-combinator-2.go
Normal file
5
Task/Y-combinator/Go/y-combinator-2.go
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
func Y(f FuncFunc) Func {
|
||||
return func(x int) int {
|
||||
return f(Y(f))(x)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue