Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Shorter code

by fizbin (Chaplain)
on Feb 23, 2005 at 04:21 UTC ( #433567=note: print w/replies, xml ) Need Help??


in reply to AI::Genetic gives me strange warnings

Yeah, it appears to be a perl bug, as I've now gotten something that demonstrates this problem without using AI::Genetic:

#!/usr/bin/perl use strict; use warnings; package yo; use Data::Dumper; sub my_f { my $genes = shift; my @order = (0,1,2,3); my @sorted = sort { local $SIG{__WARN__} = sub {print Dumper($a,$b); print @_; sleep 1 +;}; $genes->[$a] <=> $genes->[$b] } @order; my $score = $sorted[1] + 2*$sorted[2] + 3*$sorted[3]; print "DEBUG: score was $score\n"; return $score; } package main; $|=1; my @populace = map { [ map {rand 100;} (1..4) ] } (1..100); my @spopu = sort {yo::my_f($a) <=> yo::my_f($b)} @populace;
Well, hell. This sucks - I wonder if this is a documented perl bug anywhere?
-- @/=map{[/./g]}qw/.h_nJ Xapou cets krht ele_ r_ra/; map{y/X_/\n /;print}map{pop@$_}@/for@/

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://433567]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (2)
As of 2023-01-28 04:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?