codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
# @FB1 is an array of numbers that goes from 1 to 100 @FB1 = (1..100); # @FB2 is that first array # with all the values divisible by 5 and 3 # transformed into "FizzBuzz" @FB2 = map{!($_%3 or $_%5)?'FizzBuzz': $_}@FB1; # @FB3 is all the remaining numbers divisible by 3 # transformed into Fizz @FB3 = map{(/\d/ and !($_%3))?'Fizz':$_}@FB2; # @FB4 is all the remaining numbers divisible by 5 # transformed into "Buzz" @FB4 = map{(/\d/ and !($_%5))?'Buzz':$_}@FB3; # @FB5 is all values with a carriage return added to the end @FB5 = map{$_."\n"}@FB4; print @FB5; #kinda' obvious
Private
[
?
]
Run code
Submit