sed really is a powerful utility. I once wrote a tool in sed that strips HTML tags leaving just plain text as a fun exercise. Naturally it can't handle complicated cases but for many simple use cases it works. The code, though, is basically unreadable.
Given that sed is Turing complete, I'm sure if you tried harder you would have come up with a general solution ;)
A proof that Unix utility sed is Turing complete
61–70 of 109 posts
Re: A proof that Unix utility sed is Turing complete
#62In a course on algorithms I took in Moscow State Uni (Russia), we were told there are two ways to describe a Turing machine: - One with a tape & state transition table - A string & a list of string replacements Then we proved this two definitions being equal. And programmed for each ‘system’ a little. I must admit, programming with ‘string replacements’ is much much more fun than doing ‘tape & table’. Is this just so…
In my formal languages course in Germany we covered various computational models and showed the equivalences to Turing Machines. We never built complex TMs by hand, only describing how they would work. I did, however, build larger TMs by hand in a high school course.
Re: A proof that Unix utility sed is Turing complete
#63Re: A proof that Unix utility sed is Turing complete
#64sed really is a powerful utility. I once wrote a tool in sed that strips HTML tags leaving just plain text as a fun exercise. Naturally it can't handle complicated cases but for many simple use cases it works. The code, though, is basically unreadable.
Isn't it more or less a cliche that using sed etc for stripping HTML tags is unreliable and potentially hazardous? I've tried it. I could get it to apparently "work". But then I'd get some input that hosed it. Now I just use "w3m -dump". I mean, it's a browser.
Re: A proof that Unix utility sed is Turing complete
#65sed really is a powerful utility. I once wrote a tool in sed that strips HTML tags leaving just plain text as a fun exercise. Naturally it can't handle complicated cases but for many simple use cases it works. The code, though, is basically unreadable.
Isn't it more or less a cliche that using sed etc for stripping HTML tags is unreliable and potentially hazardous? I've tried it. I could get it to apparently "work". But then I'd get some input that hosed it. Now I just use "w3m -dump". I mean, it's a browser.
[0]: https://stackoverflow.com/questions/1732348/regex-match-open...
Re: A proof that Unix utility sed is Turing complete
#66And that's a bad thing. It means not only that some sed programs never complete, but it's not even possible to tell whether any given sed program hangs or not. Not something you want from a text substitution utility.
Re: A proof that Unix utility sed is Turing complete
#67And that's a bad thing. It means not only that some sed programs never complete, but it's not even possible to tell whether any given sed program hangs or not. Not something you want from a text substitution utility.
If you just want a text substitution utility, then this is proof that you can implement that by using sed in a controlled manner. Why bemoan something for doing more things than you need it to right now? This is what general-purpose computing is all about.
Re: A proof that Unix utility sed is Turing complete
#68And that's a bad thing. It means not only that some sed programs never complete, but it's not even possible to tell whether any given sed program hangs or not. Not something you want from a text substitution utility.
Re: A proof that Unix utility sed is Turing complete
#69And that's a bad thing. It means not only that some sed programs never complete, but it's not even possible to tell whether any given sed program hangs or not. Not something you want from a text substitution utility.
Re: A proof that Unix utility sed is Turing complete
#70Earlier quoted context omitted.
You're basically describing compilers. Microsoft Word probably wouldn't run on sed because it requires things outside of the capabilities of a Turing machine, like being able to produce a GUI.
Considering a GUI runs on a turing machine, how is it outside the capabilities of one? Isn't everything we do on computers exactly within the capabilities of a turing machine and just about the ingenuity to create a program that does what we want and about its efficiency? In other words, if sed is turing complete, this means you could run any other turing complete program on it. Producing a GUI is also just telling y…