Version 0 of Commands pipe

Updated 2006-12-30 20:51:06

Typing in the algorithm the way you are thinking can be much more fun then change the way you are thinking in order to fit the programming language.

Consider the follwing file: lines.txt

 line1 1 2 3 4 5 end-code1-line
 line1 2 2 3 4 5 end-code2-line
 line1 3 2 3 4 5 end-code3-line
 line1 4 2 3 4 5 end-code4-line
 line1 5 2 3 4 5 end-code5-line

In order to read the text I must open the file first, so actually I want to open the file, then read the text. In 'Python' this would be:

 file("lines.txt", "r").read()

which is exactly along my stream of thoughts.

In 'tcl' this would be:

 [read [open lines.txt r]]

which is the opposite of my stream of thoughts. I opened the file, then went back on the line and read it. This is only but a small example, and is so basic that I actually use it as a pattern when reading files.

But what if I want to extract the middle codeX word of the last word in the last sentence?