Skip to content

Instantly share code, notes, and snippets.

@semanticer
Created January 2, 2015 12:39

Revisions

  1. semanticer created this gist Jan 2, 2015.
    11 changes: 11 additions & 0 deletions Christmas Tree Core Functions
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    -- 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 '*')