Data update
This commit is contained in:
parent
8e4e15fa56
commit
72eb4943cb
1853 changed files with 35514 additions and 9441 deletions
9
Task/FizzBuzz/Nu/fizzbuzz-1.nu
Normal file
9
Task/FizzBuzz/Nu/fizzbuzz-1.nu
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
1..100 | each {
|
||||
{ x: $in, mod3: ($in mod 3), mod5: ($in mod 5), }
|
||||
| match $in {
|
||||
{ mod3: 0, mod5: 0, } => 'FizzBuz',
|
||||
{ mod3: 0, mod5: _, } => 'Fizz',
|
||||
{ mod3: _, mod5: 0, } => 'Buzz',
|
||||
_ => $in.x
|
||||
}
|
||||
} | str join "\n"
|
||||
3
Task/FizzBuzz/Nu/fizzbuzz-2.nu
Normal file
3
Task/FizzBuzz/Nu/fizzbuzz-2.nu
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
1..100 | each {
|
||||
if $in mod 15 == 0 {'FizzBuzz'} else if $in mod 3 == 0 {'Fizz'} else if $in mod 5 == 0 {'Buzz'} else {$in}
|
||||
} | str join "\n"
|
||||
6
Task/FizzBuzz/Nu/fizzbuzz-3.nu
Normal file
6
Task/FizzBuzz/Nu/fizzbuzz-3.nu
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
1..100 | each {(
|
||||
if $in mod 15 == 0 {'FizzBuzz'}
|
||||
else if $in mod 3 == 0 {'Fizz'}
|
||||
else if $in mod 5 == 0 {'Buzz'}
|
||||
else {$in}
|
||||
)} | str join "\n"
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
: fizz? ( s-f ) 3 mod 0 = ;
|
||||
: buzz? ( s-f ) 5 mod 0 = ;
|
||||
: num? ( s-f ) dup fizz? swap buzz? or 0 = ;
|
||||
: ?fizz ( s- ) fizz? [ "Fizz" puts ] ifTrue ;
|
||||
: ?buzz ( s- ) buzz? [ "Buzz" puts ] ifTrue ;
|
||||
: ?num ( s- ) num? &putn &drop if ;
|
||||
: fizzbuzz ( s- ) dup ?fizz dup ?buzz dup ?num space ;
|
||||
: all ( - ) 100 [ 1+ fizzbuzz ] iter ;
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
needs math'
|
||||
: <fizzbuzz>
|
||||
[ 15 ^math'divisor? ] [ drop "FizzBuzz" puts ] when
|
||||
[ 3 ^math'divisor? ] [ drop "Fizz" puts ] when
|
||||
[ 5 ^math'divisor? ] [ drop "Buzz" puts ] when putn ;
|
||||
: fizzbuzz cr 100 [ 1+ <fizzbuzz> space ] iter ;
|
||||
26
Task/FizzBuzz/Retro/fizzbuzz.retro
Normal file
26
Task/FizzBuzz/Retro/fizzbuzz.retro
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
( empty string result to display result )
|
||||
~~~
|
||||
|
||||
'result var
|
||||
' s:format !result
|
||||
|
||||
'number var
|
||||
#1 !number
|
||||
|
||||
~~~
|
||||
( checks for empty string if result empty print number )
|
||||
( else append fizz for divisible by 3 and prepend buzz for divisible by 5)
|
||||
( if; exists the word fizzbuzz immediately )
|
||||
~~~
|
||||
|
||||
:fizzbuzz (-)
|
||||
@number #3 mod #0 eq? [ 'fizz @result s:append !result ] if
|
||||
@number #5 mod #0 eq? [ 'buzz @result s:prepend !result ] if
|
||||
' @result s:eq? [ @number n:put nl ] if;
|
||||
' @result s:eq? not [ @result s:put nl ] if;
|
||||
;
|
||||
|
||||
[ fizzbuzz 'result var
|
||||
' s:format !result @number #1 + !number @number #100 lteq? ] while
|
||||
|
||||
~~~
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
!yamlscript/v0
|
||||
!YS-v0
|
||||
|
||||
defn main(n=100):
|
||||
each x (1 .. n): !:say
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
const print = @import("std").debug.print;
|
||||
pub fn main() void {
|
||||
var i: usize = 1;
|
||||
while (i <= 100) : (i += 1) {
|
||||
|
||||
for(1..101) |i| {
|
||||
if (i % 3 == 0 and i % 5 == 0) {
|
||||
print("FizzBuzz\n", .{});
|
||||
} else if (i % 3 == 0) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue