YAPC::EU 2018 Glasgow Update!
This commit is contained in:
parent
22f33d4004
commit
4e2d22a71d
1170 changed files with 15042 additions and 3047 deletions
18
Task/FizzBuzz/Factor/fizzbuzz-2.factor
Normal file
18
Task/FizzBuzz/Factor/fizzbuzz-2.factor
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
USING: kernel sequences arrays generalizations fry math math.parser prettyprint ;
|
||||
IN: fizzbuzz
|
||||
|
||||
: zz ( m seq -- v ) dup length 1 <array> V{ } clone 4 -nrot 1 4 -nrot 3 nrot
|
||||
'[ dup _ <= ]
|
||||
3 -nrot
|
||||
'[
|
||||
"" _ [ _ [ swap execute( str n -- str n ) ] change-nth ] each-index
|
||||
dup empty? [ drop dup number>string ] [ ] if swapd suffix! swap 1 +
|
||||
]
|
||||
while drop ;
|
||||
|
||||
: fizz ( str n -- str n ) dup 3 < [ 1 + ] [ drop "Fizz" append 1 ] if ;
|
||||
: buzz ( str n -- str n ) dup 5 < [ 1 + ] [ drop "Buzz" append 1 ] if ;
|
||||
: FizzBuzz ( m -- v ) { fizz buzz } zz ;
|
||||
: FizzBuzz-100 ( -- ) 100 FizzBuzz . ;
|
||||
|
||||
MAIN: FizzBuzz-100
|
||||
Loading…
Add table
Add a link
Reference in a new issue