Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> For example my python interpreter imports my custom List and Path classes and I could just do the following to get the same result:

  List(List(Path("filepath").read_text_file().splitlines()).group_by_key(lambda x:x).items()).map(lambda x:(len(x[1]),x[0])).sorted()
... But I don't know why you would, because with builtins and the standard library you can already do

  sorted((count, line) for (line, count) in Counter(Path("filepath").read_text().splitlines()).items())
> and if used often enough, it could made an utility method:

Sure, but you can do that for any functionality in any practical language.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: