in reply to Boolean array indexing
First shot is to let map do the grep's work:
#! /usr/bin/env perl use strict; use warnings; my @a = ( 6,7,8 ); my @b = ( 3,2,1 ); my @c = map { $b[$_] > 1 ? $a[$_] : () } 0 .. $#a; print "@c\n";
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Boolean array indexing
by johnmillerflorida (Initiate) on Nov 21, 2013 at 22:28 UTC | |
by hdb (Monsignor) on Nov 21, 2013 at 22:38 UTC | |
by GrandFather (Saint) on Nov 21, 2013 at 22:35 UTC | |
by hdb (Monsignor) on Nov 21, 2013 at 22:49 UTC |
In Section
Seekers of Perl Wisdom