Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re^3: min and mindex

by Kenosis (Priest)
on Nov 06, 2012 at 19:07 UTC ( #1002561=note: print w/replies, xml ) Need Help??

in reply to Re^2: min and mindex
in thread min and mindex

Perhaps something like the following:

use strict; use warnings; use List::Util 'min'; my %array1Hash; my @array1 = ( 5, 2, 1, 4, 1, 6, 7 ); my @array2 = ( "a", "b", "c", "d", "e", "f", "g" ); push @{ $array1Hash{ $array1[$_] } }, $_ for 0 .. $#array1; my %array2Hash = map { $_ => $array2[$_] } 0 .. $#array2; my $array1Min = min @array1; my $positions = join ', ', @{ $array1Hash{$array1Min} }; my $elements = join ', ', map $array2Hash{$_}, @{ $array1Hash{$array1 +Min} }; print 'The minimum value in @array1 is ', "$array1Min.\n"; print 'The position(s) of ', $array1Min, ' in @array1: ', "$positions. +\n"; print 'The element(s) in @array2 at position(s) ', "$positions: $eleme +nts.";


The minimum value in @array1 is 1. The position(s) of 1 in @array1: 2, 4. The element(s) in @array2 at position(s) 2, 4: c, e.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1002561]
[LanX]: hippo you asked about translating Asterix ?
[Eily]: Maybe the puns in his dialogues were somehow kept through translation, but I can tell he lost his accent
[LanX]: qui?
[Eily]: Astérix
1nickt gives up on finding a Perl YAML parser that supports hash merging. In 2017.
[LanX]: Oh yes true, he lost his accent! xD
[Eily]: and since his name is a modified version of astérisque (asterisk), which is a typographical symbol, I think it's even funnier that he would lose a diacritic

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (13)
As of 2017-05-24 14:56 GMT
Find Nodes?
    Voting Booth?