in reply to The FizzBuzz Thing :(
choroba made all the right points. Problem is generating an array that doesn’t contain what you think it does and multiple inline print statements where one, without the map, would do. Your answer isn’t bad for someone who is not a hacker and hasn’t touched Perl in 3 years. Good habits and best practices come over time. This was mine from way back when (it does not take advantage of the reuse of the 3/5 to fizz . buzz so it’s not ideal but it is idiomatic :P)–
#!perl -l print !( $_ % 15) ? "FizzBuzz" : !( $_ % 5 ) ? "Buzz" : !( $_ % 3 ) ? "Fizz" : $_ for 1 .. 100;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: The FizzBuzz Thing :(
by Anonymous Monk on Dec 25, 2015 at 21:09 UTC | |
by Your Mother (Archbishop) on Dec 25, 2015 at 21:22 UTC |