There are several commands that are very powerful; such as the command "cat".
The word cat comes from the word concatenate; it is commonly used in various languages. For example, cat in unix connects/links the file content to the monitor.
The cat command can be "infinitely" long; it contains/links a mixture of expressions and statements; the last one is normally an expression, which happens to be the return value. (sometimes, I wonderwhat if the right most one is a statement; does it evaluate and return? e.g a=7 does it return a true or false or return a value for the assignment )
Here is an example:
cat(s==0,i==1,while(le(i,N),s==s+p[i],i==i+1), 5*s)
the command line contains two assignments, one loop, one return value. In plain English, the above line says that we assign 0 to s and 1 to i; then we check whether i is smaller or equal to N or not, if yes, we add up all the p elements, and move up the counter i to the next one; when this thing done, we evaluate the expression 5 multiplied by s and return it if there is a holder for it.
if we write in C++, it may look like this
for (s=0, i=1; i <=N; i++) s+=p[i]; return 5*s;
For a simple loop, one may wonder why bother using cat (my kid used to ask me why write several lines to calculate the sum of 3 numbers, in a similar way); the beauty of using cat is for complicated cases; it is very powerful and it is cleanly structured. moreover, nesting is permitted.
Imagine the whole thing is named; how more powerful can we get?
I personally admire the beautiful mind from where these nice things flew out.
No comments:
Post a Comment