3 ms·
On what occasion would a one-liner be useful? I'm genuinely curious, because I can't think of any such case, but I wouldn't doubt there being a few.
by mrks_ 11y ago
On what occasion would a one-liner be useful? I'm genuinely curious, because I can't think of any such case, but I wouldn't doubt there being a few.
- rplnt 11y agoRead the previous sentence :)
- gknoy 11y agoCommand line use. You grep some files, and think, "man, this really needs this ONE LITTLE FILTER". So, you pipe it to `perl -e "..."`, and soon have a very short program that you iterate on a few times to make sure you have right, and then you pipe it through the rest of the toolchain. I don't write Perl much anymore, but that was far and away my __favorite__ way to use it. I love coding in Python now, more than I ever liked programming in any language (except perhaps lisp), but I still don't feel I can use it on the command line that way. In the context of a Python program, I can't see the value of a Lovecraftian lambda (unless maybe in code golf comments?), but I found this article very appealing mainly because it's quite a feat. Doing anything nontrivial in a lambda is a pain in the ass, so the fact that someone wrote a tool to do it is awesome.