Re:Fun with a Functional Programming Interview Question
by riwsky on Saturday February 06, 2021 @10:49PM
(#26052479)
meanwhile python be out here like:
[ Parent
| on HN ]
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 .