Earlier quoted context omitted.
I think you've mistaken my argument. I didn't say that the Python version looks good or is the best way to do it. It's not. I was saying that "something that is long and full of moving parts" is easier to read than something that is short and idiomatic. I am not saying either of them represent the ideal way to do it. My definition of readability includes the ability to convey the programmer's intention to the mind of…
The reader should be able to work out what is intended by the code with minimal requirements placed on them.... That's where the argument goes wrong, if the idea of "minimal requirements" means "avoid idioms".
Nastiest Python list comprehension ever
51–55 of 55 posts
Re: Nastiest Python list comprehension ever
#52Earlier quoted context omitted.
I think you've mistaken my argument. I didn't say that the Python version looks good or is the best way to do it. It's not. I was saying that "something that is long and full of moving parts" is easier to read than something that is short and idiomatic. I am not saying either of them represent the ideal way to do it. My definition of readability includes the ability to convey the programmer's intention to the mind of…
The reader should be able to work out what is intended by the code with minimal requirements placed on them.... That's where the argument goes wrong, if the idea of "minimal requirements" means "avoid idioms".
Re: Nastiest Python list comprehension ever
#53Earlier quoted context omitted.
Are you sure that's Perl? Are you sure it's not... nothing? Seriously, I cannot fathom why this would work, let alone how. The syntax is completely alien to me.
I am sure that this is Perl. Let me build it up as it executes. First, pop returns the last element of an array. If no array is specified, @_ is used, which is the default array into which function arguments are passed. Therefore pop gets at the last argument. If this function is called with one argument, it gets at the first argument. sub sieve3 { pop } Next .. is the range operator. It builds up a list from one num…
Re: Nastiest Python list comprehension ever
#54Earlier quoted context omitted.
Are you sure that's Perl? Are you sure it's not... nothing? Seriously, I cannot fathom why this would work, let alone how. The syntax is completely alien to me.
Add some spaces: sub sieve { sub p { $_[0] , @_>1 ? p(grep$_%$_[0],@_) : 1; } p(2..pop) } And if you get rid of some terse syntax: sub p { my ($first, @rest) = @_; if (@rest > 1){ return $first, p(grep { $_ % $first } @rest); } return 1; } sub sieve { my $arg = shift; return p(2..$arg) } BTW, you can even have Perl do this automatically for you, by running: $ perl -MO=Deparse sub p { $_[0], @_ > 1 ? p(grep(($_ % $_[0…
Re: Nastiest Python list comprehension ever
#55Earlier quoted context omitted.
The reader should be able to work out what is intended by the code with minimal requirements placed on them.... That's where the argument goes wrong, if the idea of "minimal requirements" means "avoid idioms".
Well, I'd welcome an explanation of your opinion here.