groupBy predicates: unary, binary, or both?
w0rp via Digitalmars-d
digitalmars-d at puremagic.com
Thu Jul 3 03:48:52 PDT 2014
I'm sorry to bump up an old thread, but whatever happened to
this? I was just using 'groupby' in Python for a common data
migration pattern I've developed...
# Build a dictionary of parent -> child relationships
# from a datbase query, for quick and dirty data migration.
# This runs in linear time.
{
y[0], tuple(y[1])
for y in
groupby(
some_query_func(
"SELECT parent_id, ... "
# ...
"ORDER BY parent_id "
),
lambda x: x["parent_id"]
)
}
... and I was thinking "it would be nice to have this in D, too!"
More information about the Digitalmars-d
mailing list