(originally posted December 02, 2009, 21:44)
## `*` is the hyper of `+`, `^` is the hyper of `*`
> hyper <- function(fn) function(a,b) Reduce(fn, rep(a,b))
> compose <- function(fn1,fn2) function(x) fn1(fn2(x))
> hyperoperation <- function(n) Reduce(compose,listRep(hyper,n))(`+`)
('rep(obj,n)' and 'listRep(obj,n)' just return a list containing
(
Read more... )
Comments 14
P.S. that essay is great!
Reply
Have you seen the Gödel CAPTCHA: http://www.scottaaronson.com/writings/captcha.html
Reply
> fact <- function(n) ifelse(n==1,1,n*fact(n-1))
> fact(7)
[1] 5040
I honestly don't know why it breaks down here.
Reply
Reply
hyper <- function(fn) function(a,b) Reduce(fn, rep(a,b), right=TRUE)
foldr, not foldl.
Reply
Reply
Reply
Reply
Leave a comment