Re: seeking golfing advice
On Thu, May 17, 2012 at 3:14 AM, Aristotle Pagaltzis pagalt...@gmx.de wrote: * Mike Erickson m...@quidquam.com [2012-05-16 15:45]: If you don't care about order, but just want those elements, you can also do: keys%{{@a}} There is more than order that gets lost. If you use `keys` you also get everything back stringified – undefs are lost and references break. If you use `values` these problems go away… except that to get the odd- index elements from it you have to `reverse` the array, at which point a not-especially-golfed grep is shorter. So you'd want values%{{1,@a}} then
Re: seeking golfing advice
* Steve Fink sph...@gmail.com [2012-05-18 10:25]: On Thu, May 17, 2012 at 3:14 AM, Aristotle Pagaltzis pagalt...@gmx.de wrote: * Mike Erickson m...@quidquam.com [2012-05-16 15:45]: If you don't care about order, but just want those elements, you can also do: keys%{{@a}} There is more than order that gets lost. If you use `keys` you also get everything back stringified – undefs are lost and references break. If you use `values` these problems go away… except that to get the odd-index elements from it you have to `reverse` the array, at which point a not-especially-golfed grep is shorter. So you'd want values%{{1,@a}} then D’oh!
Re: seeking golfing advice
From: Aristotle Pagaltzis pagalt...@gmx.de Subject: Re: seeking golfing advice To: fwp@perl.org Date: Friday, May 18, 2012, 5:29 AM * Steve Fink sph...@gmail.com [2012-05-18 10:25]: On Thu, May 17, 2012 at 3:14 AM, Aristotle Pagaltzis pagalt...@gmx.de wrote: * Mike Erickson m...@quidquam.com [2012-05-16 15:45]: If you don't care about order, but just want those elements, you can also do: keys%{{@a}} There is more than order that gets lost. If you use `keys` you also get everything back stringified – undefs are lost and references break. If you use `values` these problems go away… except that to get the odd-index elements from it you have to `reverse` the array, at which point a not-especially-golfed grep is shorter. So you'd want values%{{1,@a}} then D’oh! D::oh is right. You get an unwanted extra undef at the end of such list.