This commit is contained in:
Lobo 2026-01-22 11:56:01 -03:00
parent 54d12060ec
commit 80d8f87883
18 changed files with 292 additions and 76 deletions

7
examples/fibonacci.grr Normal file
View file

@ -0,0 +1,7 @@
#load("std.grr")
def fib {
0 1 dig [dup [+] dip swap] times drop
}
50 fib .

19
examples/fizzbuzz.grr Normal file
View file

@ -0,0 +1,19 @@
#load("std.grr")
def fizzbuzz? { [3 % 0 =] [5 % 0 =] bi or }
def fizz { when: 3 % 0 = ["Fizz" type]; }
def buzz { when: 5 % 0 = ["Buzz" type]; }
def fizzbuzz1 {
if: fizzbuzz?
[ [fizz] keep buzz "\n" type ]
[ . ];
}
def fizzbuzz {
0 swap times:
[ 1 + dup [fizzbuzz1] keep ];
drop
}
30 fizzbuzz