A Collection of Code Snippets in as Many Programming Languages as Possible
This project is maintained by TheRenegadeCoder
Welcome to the Baklava in Granule page! Here, you'll find the source code for this program as well as a description of how the program works.
import Bool
repeatString : Int -> String[] -> String
repeatString 0 [str] = "";
repeatString times [str] = str `stringAppend` (repeatString (times - 1) [str])
numSpaces : Int[] -> Int
numSpaces [n] = if n < 0 then 0 - n else n
numStars : Int[] -> Int
numStars [n] = 21 - 2 * numSpaces [n]
baklavaLine : Int[] -> String
baklavaLine [n] =
(repeatString (numSpaces [n]) [" "]) `stringAppend` (repeatString (numStars [n]) ["*"]) `stringAppend` "\n"
baklava : String[] -> Int[] -> Int[] -> String
baklava [lines] [n] [ne] =
if n <= ne then
lines `stringAppend` (baklavaLine [n]) `stringAppend` (baklava [lines] [n + 1] [ne])
else
lines
main : () <{Stdout}>
main = toStdout (baklava [""] [-10] [10])
Baklava in Granule was written by:
If you see anything you'd like to change or update, please consider contributing.
No 'How to Implement the Solution' section available. Please consider contributing.
No 'How to Run the Solution' section available. Please consider contributing.