Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
21
Task/General-FizzBuzz/Factor/general-fizzbuzz.factor
Normal file
21
Task/General-FizzBuzz/Factor/general-fizzbuzz.factor
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
USING: assocs combinators.extras io kernel math math.parser
|
||||
math.ranges prettyprint sequences splitting ;
|
||||
IN: rosetta-code.general-fizzbuzz
|
||||
|
||||
: prompt ( -- str ) ">" write readln ;
|
||||
|
||||
: get-factor ( -- seq )
|
||||
prompt " " split first2 [ string>number ] dip
|
||||
{ } 2sequence ;
|
||||
|
||||
: get-input ( -- assoc n )
|
||||
prompt string>number [1,b] [ get-factor ] thrice
|
||||
{ } 3sequence swap ;
|
||||
|
||||
: fizzbuzz ( assoc n -- )
|
||||
swap dupd [ drop swap mod 0 = ] with assoc-filter
|
||||
dup empty? [ drop . ] [ nip values concat print ] if ;
|
||||
|
||||
: main ( -- ) get-input [ fizzbuzz ] with each ;
|
||||
|
||||
MAIN: main
|
||||
Loading…
Add table
Add a link
Reference in a new issue