Skip to content

Commit

Permalink
Add Cuneiform FizzBuzz
Browse files Browse the repository at this point in the history
  • Loading branch information
joergen7 committed Jun 4, 2018
1 parent 6618c42 commit 2bd88d5
Showing 1 changed file with 74 additions and 0 deletions.
74 changes: 74 additions & 0 deletions cuneiform.cfl
@@ -0,0 +1,74 @@


%%====================================================================
%% Functions
%%====================================================================


def range( first : Str, last : Str ) ->
<number_lst : [Str]>

in Python *{
number_lst = [str( x ) for x in range( int( first ), int( last )+1 )]
}*


def is_multiple( number : Str, divisor : Str ) ->
<is_multiple : Bool>

in Python *{
is_multiple = int( number ) % int( divisor ) == 0
}*


%%====================================================================
%% Constants
%%====================================================================


let last : Str = 100;


%%====================================================================
%% Workflow
%%====================================================================


let <number_lst = number_lst : [Str]> =
range( first = 1,
last = last );


let fizzbuzz_lst : [Str] =
for x <- number_lst do

let <is_multiple = f : Bool> =
is_multiple( number = x,
divisor = 3 );

let <is_multiple = b : Bool> =
is_multiple( number = x,
divisor = 5 );

if ( f and b ) then "FizzBuzz"
else
if f then "Fizz"
else
if b then "Buzz"
else
x
end
end
end

: Str

end;


%%====================================================================
%% Query
%%====================================================================

fizzbuzz_lst;

0 comments on commit 2bd88d5

Please sign in to comment.