[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [jeffp@crusoe.net: [FWP] string evenness]



On Dec 1, Ronald J Kimball said:

>sub rjk {
>  my $string = shift;
>  my $l = length($string)/2;
>  my $x = abs($l - index($string, ' ', $l));
>  my $y = abs($l - rindex($string, ' ', $l));
>
>  my $p;
>
>  if ($x < $y) {
>    $p = $l + $x;
>  } else {
>    $p = $l - $y;
>  }
>
>  substr($string, $p, 1, "\n");
>}

That's almost identical to the algorithm I almost finished, when I got
your damned email. ;)

-- 
Jeff "japhy" Pinyan     japhy@pobox.com    http://www.pobox.com/~japhy/
CPAN - #1 Perl Resource  (my id:  PINYAN)       http://search.cpan.org/
PerlMonks - An Online Perl Community          http://www.perlmonks.com/
The Perl Archive - Articles, Forums, etc.   http://www.perlarchive.com/


==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe