News for hackers. Stuff that matters.
Re:Fun with a Functional Programming Interview Question by riwsky on Saturday February 06, 2021 @10:49PM (#26052479)
meanwhile python be out here like:

  [(m.group(1), len(m.group()))
   for m in re.finditer(r"([a-z])\1*", “aaaabbbcca")
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 .