(I apologise for this Python abomination):
print([{ (True, True): 'Fizzbuzz', (True, False): 'Fizz', (False, True): 'Buzz', (False, False): i }[i % 3 == 0, i % 5 == 0] for i in range(1, 101)])It's almost always easier to read if you don't indent it, though HN should probably fix their style sheets so it doesn't matter.
If I'm quoting something (another reason people often indent their comments) I will normally wrap the whole thing in * so that it is italicised.
I don't know a good way to make code stand out, maybe someone else has an idea.
Personally I prefer putting a greater than sign in front of each paragraph I am quoting / quoting from.
It’s what we do in e-mail and on most imageboards and in markdown. It’s easy to read and easy to understand that it’s a quote.
for i in 0...100 {
switch (i % 3, i % 5) {
case (0, 0): print("FizzBuzz")
case (0, _): print("Fizz")
case (_, 0): print("Buzz")
case (_, _): print("\(i)")
}
} def fizzbuzz(x) when is_integer(x) do
case {rem(x, 3), rem(x, 5)} do
{0, 0} -> "FizzBuzz"
{0, _} -> "Fizz"
{_, 0} -> "Buzz"
{_, _} -> Integer.to_string(x)
end
endIn this case, the most optimal representation of the data is the code.
Well, I could write another tool to analyse it, eg extract some statistics; I could write another tool to generate it, eg based on data.
(Maybe I'm being unfair here. I write mostly Elixir, and it's really easy in Elixir—one or two lines—to extract the AST of the body of a function defined in a given file and then work with it. It's just as easy to hold data canonically in its AST representation, and then both analyze it, and generate code from it, at runtime.)