Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

hyper operator

Name: Anonymous 2009-01-11 22:52

http://en.wikipedia.org/wiki/Hyper_operator
integralElem :: (Integral b) => [a] -> b -> a
hyper' :: (Integral a) => a -> (a -> a -> a)
hyper :: (Integral a) => a -> a -> a -> a

integralElem a b = a !! fromIntegral b

hyper' 0 = (+) . flip (^) 0
hyper' 1 = (+)
hyper' 2 = (*)
hyper' 3 = (^)
hyper' 4 = integralElem . (hyper4list)
    where hyper4list a = 1 : (zipWith (^) [a,a..] (hyper4list a))
hyper' n = integralElem . (hyperlist n)
    where hyperlist n a = 1 : (zipWith (hyper' (n-1)) [a,a..] (hyperlist n a))

hyper a n b = (hyper' n) a b


improvements to the above are welcome.

Name: Anonymous 2012-05-18 22:52

hyper _ 0 b = b + 1
hyper 2 _ 2 = 4
hyper a 1 b = a + b
hyper a _ 1 = a
hyper a 2 b = a * b
hyper _ _ 0 = 1
hyper 0 _ _ = 0
hyper 1 _ _ = 1
hyper a 3 b = a ^ b
hyper a 4 b = foldl1' (flip (^)) $ genericReplicate b a
hyper a n b = foldl1' (flip (flip hyper (n - 1))) $ genericReplicate b a

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List