frame_transpiler icon indicating copy to clipboard operation
frame_transpiler copied to clipboard

Fizzbuzz Frame test

Open frame-lang opened this issue 1 year ago • 0 comments

// This program is a Frame solution for this HackerRank problem: https://www.hackerrank.com/challenges/fizzbuzz/problem

`import sys`
`import math`

fn main {
    #FizzBuzz(>(1))
}

#FizzBuzz [>[i:int]]

  -machine-

  $Fizz
    |>| [i:int]
    
      i > 100 ?
        -> "i > 100" $End ^
      :|

      math.fmod(i,3) == 0 ?
        print("Fizz",end="")
        -> (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) "i % 5 == 0" $Fizz ^
      :|

      fizzed ?
        print("")
        -> (i+1) "fizzed" $Fizz ^
      :|

      -> (i) "! mod3 | mod5" $Digit ^

   $Digit
      |>| [i:int]
        print(i)
        ->  (i+1)  "loop" $Fizz ^

   $End

##

frame-lang avatar Dec 14 '23 06:12 frame-lang