Last active
September 24, 2023 15:41
-
-
Save frame-lang/05e66f6a52f285303ddc36c295966fd7 to your computer and use it in GitHub Desktop.
FizzBuzz Frame System Notation (FSN)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- This program is a Frame solution for this HackerRank problem: https://www.hackerrank.com/challenges/fizzbuzz/problem | |
`import sys` | |
`import math` | |
#![generate_frame_event] | |
fn main { | |
#FizzBuzz(>(1,false)) | |
} | |
#FizzBuzz [>[i:int,newline:bool]] | |
-machine- | |
$Fizz | |
|>| [i:int,newline:bool] | |
i > 100 ? | |
-> "i > 100" $End ^ | |
:: | |
newline ? printnl() :: | |
math.fmod(i,3) == 0 ? | |
print("Fizz") | |
-> (i, true) "i % 3 == 0" $Buzz | |
: | |
-> (i, false) "i % 3 != 0" $Buzz | |
:: ^ | |
$Buzz | |
|>| [i:int,fizzed:bool] | |
math.fmod(i,5) == 0 ? | |
print("Buzz") | |
-> (i+1,true) "i % 5 == 0" $Fizz ^ | |
:: | |
fizzed ? | |
-> (i+1,true) "fizzed" $Fizz ^ | |
:: | |
-> (i) "! mod3 | mod5" $Digit ^ | |
$Digit | |
|>| [i:int] | |
print(i) | |
-> (i+1,true) "loop" $Fizz ^ | |
$End | |
-actions- | |
print [msg] { | |
``` | |
print(msg,end="") | |
``` | |
} | |
printnl { | |
``` | |
print("") | |
``` | |
} | |
## |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment