Published on 20 October 2018 (Updated: 26 March 2019)

Welcome to the Baklava in Haskell page! Here, you'll find the source code for this program as well as a description of how the program works.

Current Solution

moduleMainwheremain::IO()main=putStrLnbaklava-- Create baklava where the top has 10 spaces and then 1 asteriskbaklava::Stringbaklava=baklavaGrow101-- Recursively grow the baklava until spaces <= zerobaklavaGrow::Int->Int->StringbaklavaGrowspaceasterisk|space<=0=line0asterisk++"\n"++baklavaShrink1(asterisk-2)|otherwise=linespaceasterisk++"\n"++baklavaGrow(space-1)(asterisk+2)-- Recursively shrink the baklava until asterisks <= zerobaklavaShrink::Int->Int->StringbaklavaShrinkspaceasterisk|asterisk<=1=linespace1|otherwise=linespaceasterisk++"\n"++baklavaShrink(space+1)(asterisk-2)-- Return a single line of the baklavalinespaceasterisk=replicatespace' '++replicateasterisk'*'