Data update

This commit is contained in:
Ingy döt Net 2025-06-11 20:16:52 -04:00
parent 72eb4943cb
commit 4d5544505c
2347 changed files with 62432 additions and 16731 deletions

View file

@ -1,7 +1,2 @@
USING: math kernel io math.functions math.parser math.ranges ;
IN: fizzbuzz
: fizz ( n -- str ) 3 divisor? "Fizz" "" ? ;
: buzz ( n -- str ) 5 divisor? "Buzz" "" ? ;
: fizzbuzz ( n -- str ) dup [ fizz ] [ buzz ] bi append [ number>string ] [ nip ] if-empty ;
: main ( -- ) 100 [1,b] [ fizzbuzz print ] each ;
MAIN: main
USE: math.parser
1 101 [ [ 3 5 [ mod 0 = ] bi-curry@ bi "Fizz" "Buzz" swapd [ and ] 2bi@ append ] keep number>string or print ] each-integer-from

View file

@ -1,19 +1,7 @@
USING: kernel sequences arrays generalizations fry math math.parser prettyprint ;
USING: math kernel io math.functions math.parser math.ranges ;
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 ;
: quxx ( str n -- str n ) dup 7 < [ 1 + ] [ drop "Quxx" append 1 ] if ;
: FizzBuzzQuxx ( m -- v ) { fizz buzz quxx } zz ;
: FizzBuzzQuxx-100 ( -- ) 100 FizzBuzzQuxx . ;
MAIN: FizzBuzzQuxx-100
: fizz ( n -- str ) 3 divisor? "Fizz" "" ? ;
: buzz ( n -- str ) 5 divisor? "Buzz" "" ? ;
: fizzbuzz ( n -- str ) dup [ fizz ] [ buzz ] bi append [ number>string ] [ nip ] if-empty ;
: main ( -- ) 100 [1,b] [ fizzbuzz print ] each ;
MAIN: main

View file

@ -1,24 +1,19 @@
USING: io kernel math math.functions math.parser ranges
sequences ;
IN: rosetta-code.fizz-buzz
USING: kernel sequences arrays generalizations fry math math.parser prettyprint ;
IN: fizzbuzz
PREDICATE: fizz < integer 3 divisor? ;
PREDICATE: buzz < integer 5 divisor? ;
: 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 ;
INTERSECTION: fizzbuzz fizz buzz ;
: 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 ;
: quxx ( str n -- str n ) dup 7 < [ 1 + ] [ drop "Quxx" append 1 ] if ;
: FizzBuzzQuxx ( m -- v ) { fizz buzz quxx } zz ;
: FizzBuzzQuxx-100 ( -- ) 100 FizzBuzzQuxx . ;
GENERIC: fizzbuzz>string ( n -- str )
M: fizz fizzbuzz>string
drop "Fizz" ;
M: buzz fizzbuzz>string
drop "Buzz" ;
M: fizzbuzz fizzbuzz>string
drop "FizzBuzz" ;
M: integer fizzbuzz>string
number>string ;
MAIN: [ 1 100 [a..b] [ fizzbuzz>string print ] each ]
MAIN: FizzBuzzQuxx-100

View file

@ -0,0 +1,24 @@
USING: io kernel math math.functions math.parser ranges
sequences ;
IN: rosetta-code.fizz-buzz
PREDICATE: fizz < integer 3 divisor? ;
PREDICATE: buzz < integer 5 divisor? ;
INTERSECTION: fizzbuzz fizz buzz ;
GENERIC: fizzbuzz>string ( n -- str )
M: fizz fizzbuzz>string
drop "Fizz" ;
M: buzz fizzbuzz>string
drop "Buzz" ;
M: fizzbuzz fizzbuzz>string
drop "FizzBuzz" ;
M: integer fizzbuzz>string
number>string ;
MAIN: [ 1 100 [a..b] [ fizzbuzz>string print ] each ]