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 2009-02-06 5:00

{
hyper ->
    stef(;a,n,b)
    staðvær r
    stofn
        ef n=0 þá
            b+1,
        annarsef a=2 & b=2 þá
            4,
        annarsef n=1 þá
            a+b,
        annarsef b=1 þá
            a,
        annarsef n=2 þá
            a*b,
        annarsef b=0 þá
            1,
        annarsef a=0 þá
            0,
        annarsef a=1 þá
            1,
        annars
            fyrir( r:=a ; b>1 ; b:=b-1 ) lykkja
                r := hyper(;a,n-1,r),
            lykkjulok,
            r,
        eflok
    stofnlok
}

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