2 ms·
"Unnecessary"? You can't just change the problem! I was asking for the equivalent of some particular piece of code using a list, not a different one using a gen
by dataflow 4y ago
"Unnecessary"? You can't just change the problem! I was asking for the equivalent of some particular piece of code using a list, not a different one using a generator. Sometimes you want a generator, sometimes you want an array. In either language.
- eterm 4y agoThis is a silly argument, you're asking for a literal translation of a pythonic problem without allowing the idioms from the other languages. If you were actually trying to solve the problem in dotnet, you'd almost certainly structure it as the Queryable result and then at the very end after composing run ToList, or ToArray or consume in something else that will enumerate it. We can also shorten it further to: Enumerable.Range(1, 50) .Where(e => e % 12 == 1) .Skip(2) .ToList() Now even including the ToList it's now just four basic steps: Range, Filter, Skip, Enumerate. Those are the very basics, all one line if wanted. It doesn't get much more basic than that, and I'd still argue it's easier for someone new to programming to see what's going on in the C# than the python example. edit: realised the maths simplifies it even further.