From: Edward Faulkner Date: 2005-10-22T05:22:07+09:00 Subject: Re: array in hash... argh!! --Xm/fll+QQv+hsKip Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Oct 22, 2005 at 05:09:17AM +0900, Simon Strandgaard wrote: > a bit shorter.. >=20 > res =3D h.values.transpose.map{|ary| h.keys.zip(ary)}.map{|pairs| Hash[*p= airs]} Ah, transpose! That's what I was looking for. And as long as we're golfing... no need for two maps: res =3D h.values.transpose.map{|ary| Hash[*h.keys.zip(ary).flatten]} regards, Ed --Xm/fll+QQv+hsKip Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFDWU1ZnhUz11p9MSARAjFpAKC6gXHRWte8F/DKewY8S7/gj4cU+QCfcDKG vk5er25PpBnWN3HrINpwAPo= =SJrJ -----END PGP SIGNATURE----- --Xm/fll+QQv+hsKip--