Skip to content

Instantly share code, notes, and snippets.

@saml
Created April 20, 2013 11:34
Show Gist options
  • Save saml/5425696 to your computer and use it in GitHub Desktop.
Save saml/5425696 to your computer and use it in GitHub Desktop.
int f(int x, int y) {
for (; x >= cutoff; x--) {
y = (y <= 0) ? 1 : f(x, y - 1);
}
return g(x,y);
}
@danr
Copy link

danr commented Apr 20, 2013

f :: Int -> Int -> Int -> (Int,Int)
f cutoff = go where
    go x y
        | not (x >= cutoff) = (x,y)
        | y <= 0            = (x-1,1)
        | otherwise         = go (x-1) (y-1)

-- I conjecture that f can be calculated in constant time

g :: Int -> Int -> a
g = undefined

bla :: Int -> Int -> a
bla x y = uncurry g (f 100 x y)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment