This is the first question for this language, and I decided I would do a FizzBuzz.
I used a template literal as a proof of concept, same goes for the pipe (|>). The code creates a function that recreates the traditional FizzBuzz in FreezeFlame:
var fizzBuzz = (max) -> { for(var i = 0; i < max + 1; i++) { (if i % 3 === 0 || i % 5 === 0 then "#{i % 3 == 0 ? 'Fizz' : ''}#{i % 5 === 0 ? 'Buzz' : ''}" else i) |> console.log } } This is equivalent to the following in JavaScript:
var fizzBuzz = (max) => { for(var i = 0; i < max + 1; i++){ console.log((i % 3===0||i % 5===0 ? `${i % 3 == 0 ? 'Fizz' : ''}${i % 5 === 0 ? 'Buzz' : ''}` : i)); }; } The following features are used:
- FreezeFlame ternary (
if ... then ... else ...) - FreezeFlame template literals (
)#{...} - JS ternary (
... ? ... : ...) - FreezeFlame pipe (
... |> ...) - FreezeFlame function (
(...) -> { ... })
My main worries are the testing.