Skip to content

Instantly share code, notes, and snippets.

@ryuta-ito
Created January 14, 2017 06:15
Show Gist options
  • Save ryuta-ito/b3d3bbcff5a4c72b7d05bc82c90b5634 to your computer and use it in GitHub Desktop.
Save ryuta-ito/b3d3bbcff5a4c72b7d05bc82c90b5634 to your computer and use it in GitHub Desktop.
-- N^2 ~ N
f (x, y) = (((x+y)*(x+y+1))/2) + x + 1
a n = b (0, n)
b (x, 0) = [(x, 0)]
b (x, y) = (x, y) : b (x+1, y-1)
app n = map f ([0..n] >>= a)
@ryuta-ito
Copy link
Author

-- Z ~ N
a 0 = [0]
a n = (a (n-1)) ++ [n, (n*(-1))]
f n  = if n > 0 then n*2 else n*(-1)*2+1

app n = map f (a n)

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