June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
|
|
@ -1 +1,20 @@
|
|||
repeat i 100 [case/all [i // 3 = 0 [print"fizz"] i // 5 = 0 [print "buzz"] 1 [print i]]]
|
||||
REBOL [
|
||||
Title: "FizzBuzz"
|
||||
Author: oofoe
|
||||
Date: 2009-12-10
|
||||
URL: http://rosettacode.org/wiki/FizzBuzz
|
||||
]
|
||||
|
||||
; Concatenative. Note use of 'case/all' construct to evaluate all
|
||||
; conditions. I use 'copy' to allocate a new string each time through
|
||||
; the loop -- otherwise 'x' would get very long...
|
||||
|
||||
repeat i 100 [
|
||||
x: copy ""
|
||||
case/all [
|
||||
0 = mod i 3 [append x "Fizz"]
|
||||
0 = mod i 5 [append x "Buzz"]
|
||||
"" = x [x: mold i]
|
||||
]
|
||||
print x
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,20 +1,7 @@
|
|||
REBOL [
|
||||
Title: "FizzBuzz"
|
||||
Author: oofoe
|
||||
Date: 2009-12-10
|
||||
URL: http://rosettacode.org/wiki/FizzBuzz
|
||||
]
|
||||
|
||||
; Concatenative. Note use of 'case/all' construct to evaluate all
|
||||
; conditions. I use 'copy' to allocate a new string each time through
|
||||
; the loop -- otherwise 'x' would get very long...
|
||||
|
||||
repeat i 100 [
|
||||
x: copy ""
|
||||
case/all [
|
||||
0 = mod i 3 [append x "Fizz"]
|
||||
0 = mod i 5 [append x "Buzz"]
|
||||
"" = x [x: mold i]
|
||||
]
|
||||
print x
|
||||
print switch/default 0 compose [
|
||||
(mod i 15) ["fizzbuzz"]
|
||||
(mod i 3) ["fizz"]
|
||||
(mod i 5) ["buzz"]
|
||||
][i]
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,11 +1 @@
|
|||
repeat i 100 [
|
||||
print switch/default 0 compose [
|
||||
(mod i 15) ["fizzbuzz"]
|
||||
(mod i 3) ["fizz"]
|
||||
(mod i 5) ["buzz"]
|
||||
][i]
|
||||
]
|
||||
|
||||
; And minimized version:
|
||||
|
||||
repeat i 100[j:""if 0 = mod i 3[j:"fizz"]if 0 = mod i 5[j: join j"buzz"]if j =""[j: i]print j]
|
||||
repeat i 100[j:""if i // 3 = 0[j:"fizz"]if i // 5 = 0[j: join j"buzz"]if""= j[j: i]print j]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue