Skip to content

Instantly share code, notes, and snippets.

@semanticer
Created January 2, 2015 12:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save semanticer/84fead6dfac1d3daacae to your computer and use it in GitHub Desktop.
Save semanticer/84fead6dfac1d3daacae to your computer and use it in GitHub Desktop.
-- creates tree in list structure
tree bc gf fbs = [block rows (treeMaxSp bc gf fbs) | rows <- take bc [fbs,(fbs+gf)..]]
-- counts maximal number of spaces for given tree
treeMaxSp bc gf fbs = ((bc-1)*gf)+(fbs-1)
-- creates one block with specified number of rows and maximal space
block rowCount maxSp = [row st sp | (st,sp) <- take rowCount (zip [1,3..] [maxSp,maxSp-1..0])]
-- creates one row with specified number of stars and spaces
row st sp = take sp (repeat ' ') ++ take st (repeat '*')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment