:: Re: [DNG] greybeards
Page principale
Supprimer ce message
Répondre à ce message
Auteur: Rainer Weikusat
Date:  
À: dng
Sujet: Re: [DNG] greybeards
Didier Kryn <kryn@???> writes:

[...]

>     The force which makes software development possible is, of course,
> enthusiasm, but it needs some heading.


A problem someone recently posted to comp.lang.perl.misc was "assuming
$R is a string specifiying a sequence of 1-based indices and @A an array
whose length is evenly divisble by length($R), how can the contents of
@A be reordered as specified by the indices from $R (to be applied to
each length($R) sized subset of @A in turn)?" There's an (IMHO)
extremely neat solution,

-----
my $R = '4213';
my @A = qw(aa bb cc dd ee ff gg hh ii jj kk ll);

my @r = $R =~ /./g;
my $n;
print("@A[map {(0, map $n++, @r)[@r]} 1..@A/@r]", "\n");
-----

which is the closest thing to a poem I've seen in code so far. I had the
pleasure to discover this (or it came to me --- I'd never claim to have
'invented' that) and if that's a sign of "enthusiasm", it's one of a
very different kind than taking enormous pride in creating widely
loathed, large agglomerations of clumsily written code based on the
conviction that "everything anybody else ever did was completely wrong"
...