[prev in list] [next in list] [prev in thread] [next in thread] 

List:       groovy-dev
Subject:    =?UTF-8?Q?Re=3A_=5Bgroovy=2Ddev=5D_Need_more_Map_and_Set_support=E2=80=A6?=
From:       Dinko Srkoc <dinko.srkoc () gmail ! com>
Date:       2012-10-29 9:04:14
Message-ID: CAFPyv-yPkF9nMFPDjFR2GXJKKBzHX0LNm3aJutwhoHUhzFQSnA () mail ! gmail ! com
[Download RAW message or body]

On 29 October 2012 08:16, Russel Winder <russel@winder.org.uk> wrote:
> Python has dictionary comprehensions and set comprehensions as well as
> list comprehensions.
>
> Groovy has great list and iteration tools, but quite poor support for
> doing things with maps of maps and such like. At least from what I can
> tell just now, I might be missing something.

I agree.

>
> Context is I have a map of maps and want to create a new map of maps
> with some transformations. With Python I can do this with comprehensions
> and therefore use "internal iteration" rather than "external
> iteration"(*). With Groovy it is beginning to look like I have to use
> explicit, i.e external, iteration – a very last millenium technique. :-)

Well, a combination of `inject` and `collectEntries` can get you where
you want, but yes, it is not as straightforward as with Lists.

Cheers,
Dinko

>
>
> (*) "internal iteration" and "external iteration" are terms rushing at
> the JVM-verse due to Java 8. It's basically describing what Groovy has
> had since the beginning with map, filter and reduce — oh sorry Groovy
> used the Smalltalk names for the first and last: collect, inject ;-)
> --
> Russel.
> =============================================================================
> Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder@ekiga.net
> 41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel@winder.org.uk
> London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic