12.12.10
silly shell tricks
You can use 'tac' to implement a stack.
Red comes from stdin, black is stdout:
Instead of doing `factor`:
$ factor
33
33: 3 11
19
19: 19
27
27: 3 3 3
^D
You can do this:
$ tac | factor
394
87
19
666
^D
666: 2 3 3 37
19: 19
87: 3 29
394: 2 197
$
What was reversed was the order of inputs sent to factor, not the output generated by factor. The effect is of course haveable a number of different ways:
$ echo "394 87 19 666" | factor | tac
666: 2 3 3 37
19: 19
87: 3 29
394: 2 197
and this is the same procedure however factor sees them in the order you typed them, not in their stack-reversed order. I think I can use this to my advantage someday, when I want a filter to see reversed input.
You can also flip the output over the logical y = -x line using both tac and rev; this is also mostly JFF (just for fun):
$ echo "394 87 19 666" | factor | tac | rev
73 3 3 2 :666
91 :91
92 3 :78
791 2 :493
Clearly nonsensical. These filters are transitive however!
$ echo "394 87 19 666" | factor | tac | rev | tac | rev
394: 2 197
87: 3 29
19: 19
666: 2 3 3 37
and
$ echo "394 87 19 666" | factor | tac | rev | rev | tac
394: 2 197
87: 3 29
19: 19
666: 2 3 3 37
and
$ echo "394 87 19 666" | factor | tac | tac | rev | rev
394: 2 197
87: 3 29
19: 19
666: 2 3 3 37
and
$ echo "394 87 19 666" | factor | rev | tac | tac | rev
394: 2 197
87: 3 29
19: 19
666: 2 3 3 37
and
$ echo "394 87 19 666" | factor | rev | rev | tac | tac
394: 2 197
87: 3 29
19: 19
666: 2 3 3 37
While I did not exhaust the combinations of two tacs and two revs, I feel confident knowing their properties that my conjecture holds, and I would even go so far as to say that any finite stream for which their exists sufficient RAM to process is preserved through arbitrary linear combinations of even counts of tacs and even counts of revs. A number of assumptions are of course depended upon: tac should require no more space than the streamed lines actually occupy and rev's space is constant in the number of lines and per-line, linear in the length. With clever stream pointer manipulation, both of these tools should not require to allocate additional space however.
I have decided to run into a dense jungle banging on a drum and screaming DEATH TO MONKEYS!!! Here is a map of my progress: http://piratejon.com:8080/mirror.
Comments:
<< Home
this is a piece of junk there is no red and black what is he talking about and also the link is dead wtf...!!!
Post a Comment
Subscribe to Post Comments [Atom]
<< Home