Re:Why your first Rust FizzBuzz implementation may not work
by steveklabnik on Monday October 13, 2014 @04:10AM
(#8447894)
One difference is that this won't do exhaustiveness checks, where the pattern match will.
[ Parent
| on HN ]
Re:Why your first Rust FizzBuzz implementation may not work
by Erwin on Monday October 13, 2014 @05:03AM
(#8447995)
Well, here's an exhaustively checking version. Not statically still of course.
for x in range(1,101):
print [
# %3 = 0
[ x, "Fizz" ],
[ "Buzz", "FizzBuzz"] # %5 = 0
][x%3 == 0][x%5 == 0]
(I'll note this was hard to get than if-checks and pattern matching so I won't be replacing such logic with matrices in my Python program any time soon...)
Re:Why your first Rust FizzBuzz implementation may not work
by steveklabnik on Monday October 13, 2014 @07:05AM
(#8448218)
> not statically of course
Right, but that's the point!