News for hackers. Stuff that matters.
Re:Fun with a Functional Programming Interview Question by eesmith on Sunday February 07, 2021 @03:00AM (#26053447)

  import itertools
  [(c, len(list(it))) for (c, it) in itertools.groupby("aaaabbbcca")]
It's not the first time I've wanted

  def ilen(it):
    return sum(1 for _ in it)
as part of itertools. Which would make the second line be:

  [(c, itertools.ilen(it)) for (c, it) in itertools.groupby("aaaabbbcca")]
Rejected many times, eg, from 2010: https://bugs.python.org/issue9547 .

There are no comments on this comment yet.