Skip Menu |

This queue is for tickets about the List-MoreUtils CPAN distribution.

Report information
The Basics
Id: 71930
Status: rejected
Priority: 0/
Queue: List-MoreUtils

People
Owner: Nobody in particular
Requestors: BBYRD [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: Combination of map and each for hashes
There needs to be a more elegant way to run through hash/array pairs. It seems like a few things are almost there, but don't do it in the fashion that it should look. Here's the idea: join("\n", map { "$a => $b" } %hash); In other words, a "natatime" of 2, but arranged as an automatic function, without the need of a while loop. It could be like a reduce function that only reduces it to half of its objects: a reduction of a hash into an array. This can be passed to the other functions that work off of arrays, like sort, grep, join, etc.
Ever took a look into Hash::MoreUtils? As long as I don't know what you're searching for, it's hard to decide whether to move queue or reject :P Cheers
On 2011-10-25 16:13:56, BBYRD wrote: Show quoted text
> There needs to be a more elegant way to run through hash/array pairs. > It seems like a few things are almost there, but don't do it in the > fashion that it should look. Here's the idea: > > join("\n", map { "$a => $b" } %hash); > > In other words, a "natatime" of 2, but arranged as an automatic > function, without the need of a while loop. It could be like a reduce > function that only reduces it to half of its objects: a reduction of a > hash into an array. This can be passed to the other functions that work > off of arrays, like sort, grep, join, etc.
List::Util has pairmap. Try perl -MList::Util=pairmap -E 'say join("\n", pairmap { "$a => $b" } %ENV);'
So I can close this ticket since List::Util already implements a solution.
Rejected on submitters wish.