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

I wrote that, and I gotta say sed is a much crazier target.

More sed fun: http://aurelio.net/projects/sedsokoban/



Kudos, there was also this one: http://www.cs.cmu.edu/afs/cs/Web/Groups/AI/lang/lisp/impl/aw... Possibly based on the same newsgroup post?


That 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.


Indeed. There are few wide-spread programming languages around any more that lack such things as, say, any form of arithmetic whatsoever.


sed has regular expressions. I think you could do some binary arithmetic fairly easily with regular expressions and find and replace...


Yep, 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.)


The 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.


> to show examples of things that are so awkward and inefficient


Yeah. As in, better done in awk. The opposite of awkward is sedward.




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

Search: