Skip to content
This repository was archived by the owner on Aug 5, 2024. It is now read-only.

Commit 56883cd

Browse files
committed
added fizzbuzz to examples
1 parent bc1ea6e commit 56883cd

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

examples/fizzbuzz.plv

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import prelude;
2+
3+
static printed :: bool := False;
4+
5+
static my_print (s :: string) :: () :=
6+
( printf s;
7+
printed <- True;
8+
);
9+
static my_nl (i :: int) :: () :=
10+
if printed then (
11+
printf "\n";
12+
printed <- False;
13+
) else (
14+
void $ printf "%d\n" i;
15+
);
16+
17+
main () :: int :=
18+
( for i in 1..100 -> (
19+
if i % 3 == 0 then my_print "Fizz";
20+
if i % 5 == 0 then my_print "Buzz";
21+
my_nl i;
22+
);
23+
return 0;
24+
);

0 commit comments

Comments
 (0)