develooper Front page | perl.perl6.language | Postings from May 2005

Re: reduce metaoperator on an empty list

Thread Previous | Thread Next
From:
merlyn
Date:
May 20, 2005 06:19
Subject:
Re: reduce metaoperator on an empty list
Message ID:
86u0kyc9vt.fsf@blue.stonehenge.com
>>>>> "Randal" == Randal L Schwartz <merlyn@stonehenge.com> writes:

Randal> For example, if I wanted the identity hash (where all values are 1,
Randal> but keys are original list elements), I could do:

Randal> my %hash = @somelist.inject({}, { $^a{$^b} = 1; $^a });

And yes, I know I can spell this as:

my %hash = ({}, @somelist).reduce({ $^a{$^b} = 1; $^a });

But it puts things all in the wrong place for me. :)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About