Last active
August 29, 2015 13:56
-
-
Save linse/9336770 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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