X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=blobdiff_plain;f=week3.mdwn;h=fe7c315377651754d8ed5d02062f67db7e4e5a78;hp=42f65d64d412d97e862291e4d5d3311aa527a0aa;hb=09627025337649a4b20af62151d62fd0211c2e38;hpb=4556367eaeb7208a675bc17158418acc013149f6 diff --git a/week3.mdwn b/week3.mdwn index 42f65d64..fe7c3153 100644 --- a/week3.mdwn +++ b/week3.mdwn @@ -1,5 +1,28 @@ +Even with a fold-based representation of numbers, and pred/equal/subtraction, some computable functions are going to be out of our reach. -How to do with recursion with omega. +Fibonacci: doable without Y, but takes some ingenuity + +And so on... + +Need a general method, where f(n) doesn't just depend on f(n-1) or (f(n-1),f(n-2),..). + +Looks like Ackermann function is simplest example that MUST be done with Y, Everything simpler could be done using only fixed iteration limits. + +A(y,x) = + | when x == 0 -> y + 1 + | when y == 0 -> A(x-1,1) + | _ -> A(x-1, A(x,y-1)) + +A(0,y) = y+1 +A(1,y) = y+2 +A(2,y) = 2y + 3 +A(3,y) = 2^(y+3) -3 +A(4,y) = 2^(2^(2^...2)) [y+3 2s] - 3 + + +Some algorithms can also be done more efficiently / intelligibly with general mechanism for recursion. + +How to do recursion with omega. fixed point combinators