5 ms·
Ahahah. Awesome. There is even an 'awk' version: https://github.com/darius/awklisp https://github.com/darius/awklisp
by mseri 12y ago
Ahahah. Awesome. There is even an 'awk' version: https://github.com/darius/awklisp https://github.com/darius/awklisp
- abecedarius 12y agoI wrote that, and I gotta say sed is a much crazier target. More sed fun: http://aurelio.net/projects/sedsokoban/ http://aurelio.net/projects/sedsokoban/
- breadbox 12y agoIndeed. There are few wide-spread programming languages around any more that lack such things as, say, any form of arithmetic whatsoever.
- mtdewcmu 12y agosed has regular expressions. I think you could do some binary arithmetic fairly easily with regular expressions and find and replace...
- breadbox 12y agoYep, that's pretty much how you have to do it. (If all you need is increment/decrement, though, you can actually do it pretty concisely with decimal-digit strings. Skipping the binary-to-decimal conversion greatly simplifies displaying numerical values.)
- mtdewcmu 12y agoThe GNU sed manual has examples like that at the end. It always seemed odd to show examples of things that are so awkward and inefficient. If they meant for sed to do those things, presumably they would have made commands for them.
- userbinator 12y ago> to show examples of things that are so awkward and inefficient
- deleted 12y ago[deleted]
- mtdewcmu 12y agoYeah. As in, better done in awk. The opposite of awkward is sedward.
- mzs 12y agoKudos, there was also this one: http://www.cs.cmu.edu/afs/cs/Web/Groups/AI/lang/lisp/impl/awk/0.html http://www.cs.cmu.edu/afs/cs/Web/Groups/AI/lang/lisp/impl/aw... Possibly based on the same newsgroup post?
- abecedarius 12y agoThat one's a cooler hack because it runs in old awk, from before they supported user-defined functions. The whole read-eval-print composition is a straight-line series of loops, with the recursions unrolled into explicit stack manipulation. If you want to see how to write fairly readable code within those restrictions, it's instructive. It even has a cooler name. (I said so when bringing it up in my documentation.) On the other hand, awklisp has some value as a readable Lisp interpreter in a lower-level but still reasonable language, in between the usual Lisp-in-Lisp and Lisp-in-C tutorials.
- mtdewcmu 12y agoThat's kind of funny, because awk is already a programming language.