Skip to content

Instantly share code, notes, and snippets.

@linse
Last active August 29, 2015 13:56
Show Gist options
  • Save linse/9336770 to your computer and use it in GitHub Desktop.
Save linse/9336770 to your computer and use it in GitHub Desktop.
-- this is very simple and also ambiguous, e.g. the open structure will be constructed multiple times
s :: Integer -> [String]
s 2 = [".."]
s 1 = ["."]
s n = (map inbrackets $ s (n-2)) ++ (map adddot $ s (n-1) ) ++ (concatMap branches (splits n))
where
inbrackets a = "("++a++")"
adddot a = '.':a
branches (a,b) = [a'++b' | a' <- s a, b' <- s b ]
splits n = [ (k, n-k) | k <- [ 3 .. n-1 ]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment