Skip to content

Commit

Permalink
Add Baklava in Granule (#4184)
Browse files Browse the repository at this point in the history
  • Loading branch information
rzuckerm authored Jan 1, 2025
1 parent 62e8a7c commit ed66a2a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
25 changes: 25 additions & 0 deletions archive/g/granule/baklava.gr
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
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])
4 changes: 2 additions & 2 deletions archive/g/granule/testinfo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ folder:

container:
image: "rzuckerm/granule"
tag: "0.9.5.0-4"
cmd: "gr --no-info --no-print-return-value {{ source.name }}{{ source.extension }}"
tag: "0.9.6.0-6"
cmd: "gr --no-info --no-print-return-value --include-path=/usr/local/lib {{ source.name }}{{ source.extension }}"

0 comments on commit ed66a2a

Please sign in to comment.