Jarqwiz
Microsoft Employees Being Put in Charge of Linux
Clippy is removing its plugin interface
Ask HN: What do you think of Microsoft owning GitHub?
Tell me what you think. Is it any good? Did you stop using Github? Maybe something else entirely.
Re:Ask HN: What is the most beautiful piece of code you've ever read?
on Monday October 28, 2019 @04:04AM (#21375084)
For me it's a function that calculates factorial using iterators in Rust:
fn factorial(i: u64) -> u64 {
(1..=i).product()
}
In almost every other language this code would look messy or use some terrible recursion.For example in C it would look something like this:
long factorial(int n)
{
int c;
long result = 1;
for (c = 1; c <= n; c++)
result = result * c;
return result;
}
Or with recursion: long factorial(int n)
{
if (n == 0)
return 1;
else
return(n * factorial(n-1));
}
In any case, I thin Rust looks better in every way with its cleaner syntax.