On Sat, Aug 5, 2017 at 2:50 AM, Sean McAfee <eef...@gmail.com> wrote:
> On Fri, Aug 4, 2017 at 10:18 PM, ToddAndMargo <toddandma...@zoho.com> > wrote: > >> On 08/04/2017 08:43 PM, Bruce Gray wrote: >> >>> >>> P6-ish version: >>> ifconfig | perl6 -e 'say lines.map({ ~$0 if /^(\S+) ": flags="/ >>> }).sort[1]' >>> >> >> > Wait a second. How does map skip input elements like that? > > > map { $_ if $_ %% 2 }, 1..10 > (2 4 6 8 10) > > > 1 if 1 %% 2 > () > > But: > > > map { $_ %% 2 ?? $_ !! () }, 1..10 > (() 2 () 4 () 6 () 8 () 10) > Perl 5 doesn't do nested lists (unless you use arrayrefs) so () flattens away. In Perl 6, to get a similar effect you produce Nil. As Nil is the default value in that first block, it gets produced if the condition fails. -- brandon s allbery kf8nh sine nomine associates allber...@gmail.com ballb...@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net