3 ms·
I wouldn't trust it to win a fight with the borrow checker in Rust but lots of simple and practical cases work, such as "use comprehensions to give me a sum of
by PaulHoule 2y ago
I wouldn't trust it to win a fight with the borrow checker in Rust but lots of simple and practical cases work, such as "use comprehensions to give me a sum of the square of all element divisible by three"?
sum(x**2 for x in numbers if x % 3 == 0)
and to do the same for a pandas series with pandas operators after asking it to inline something
(numbers[numbers % 3 == 0] ** 2).sum()
It's not a miracle, you have to go at it with some critical thinking and testing and it makes mistakes but so does Stack Overflow.
- lblume 2y agoIn the first case, I would literally type out the expression faster than thinking about expressing it in natural language.