Code

Imported upstream SVN snapshot 1.4~rc2+20090928.
[pkg-rrdtool.git] / doc / rpntutorial.txt
index aa95f7b51e2f11abd5b0a05607d92c52f3c56af6..a99fa431c101a0122b8431884239c0144440ea80 100644 (file)
@@ -19,8 +19,8 @@ R\bRe\bea\bad\bdi\bin\bng\bg C\bCo\bom\bmp\bpa\bar\bri\bis\bso\bon\bn O\bOp\bpe\ber\bra\bat\bto\bor\brs\bs
 
        For example, think about "2,1,GT".  This RPN expression could be read
        as "is two greater than one?"  The answer to that question is "true".
-       So the three values should be replaced with "1".  Thus the RPN expres-
-       sion 2,1,GT evaluates to 1.
+       So the three values should be replaced with "1".  Thus the RPN
+       expression 2,1,GT evaluates to 1.
 
        Now consider "2,1,LE".  This RPN expression could be read as "is two
        less than or equal to one?".   The natural response is "no" and thus
@@ -33,8 +33,8 @@ R\bRe\bea\bad\bdi\bin\bng\bg t\bth\bhe\be I\bIF\bF O\bOp\bpe\ber\bra\bat\bto\bor\br
        So the IF operator acts on only one value on the stack: the third value
        to the left of the IF value.  The second value to the left of the IF
        corresponds to the true ("Y") branch.  And the first value to the left
-       of the IF corresponds to the false ("Z") branch.  Read the RPN expres-
-       sion "X,Y,Z,IF" from left to right like so: "if X then Y else Z".
+       of the IF corresponds to the false ("Z") branch.  Read the RPN
+       expression "X,Y,Z,IF" from left to right like so: "if X then Y else Z".
 
        For example, consider "1,10,100,IF".  It looks bizarre to me.  But when
        I read "if 1 then 10 else 100" it's crystal clear: 1 is true so the
@@ -49,12 +49,12 @@ R\bRe\bea\bad\bdi\bin\bng\bg t\bth\bhe\be I\bIF\bF O\bOp\bpe\ber\bra\bat\bto\bor\br
        operators.
 
 S\bSo\bom\bme\be E\bEx\bxa\bam\bmp\bpl\ble\bes\bs
-       While compound expressions can look overly complex, they can be consid-
-       ered elegantly simple.  To quickly comprehend RPN expressions, you must
-       know the algorithm for evaluating RPN expressions: iterate searches
-       from the left to the right looking for an operator.  When it's found,
-       apply that operator by popping the operator and some number of values
-       (and by definition, not operators) off the stack.
+       While compound expressions can look overly complex, they can be
+       considered elegantly simple.  To quickly comprehend RPN expressions,
+       you must know the algorithm for evaluating RPN expressions: iterate
+       searches from the left to the right looking for an operator.  When it's
+       found, apply that operator by popping the operator and some number of
+       values (and by definition, not operators) off the stack.
 
        For example, the stack "1,2,3,+,+" gets "2,3,+" evaluated (as "2+3")
        during the first iteration and is replaced by 5.  This results in the
@@ -65,8 +65,8 @@ S\bSo\bom\bme\be E\bEx\bxa\bam\bmp\bpl\ble\bes\bs
         2) 1,5,+        eval is 1,5,+ = 6    result is 6
         3) 6
 
-       Let's use that notation to conveniently solve some complex RPN expres-
-       sions with multiple logic operators:
+       Let's use that notation to conveniently solve some complex RPN
+       expressions with multiple logic operators:
 
         1) 20,10,GT,10,20,IF  eval is 20,10,GT = 1     result is 1,10,20,IF
 
@@ -77,8 +77,8 @@ S\bSo\bom\bme\be E\bEx\bxa\bam\bmp\bpl\ble\bes\bs
        read pop "if 1 then 10 else 20" so push 10.  Only 10 is left so 10 is
        the answer.
 
-       Let's read a complex RPN expression that also has the traditional mul-
-       tiplication operator:
+       Let's read a complex RPN expression that also has the traditional
+       multiplication operator:
 
         1) 128,8,*,7000,GT,7000,128,8,*,IF  eval 128,8,*       result is 1024
         2) 1024,7000,GT,7000,128,8,*,IF     eval 1024,7000,GT  result is 0
@@ -126,8 +126,8 @@ S\bSo\bom\bme\be E\bEx\bxa\bam\bmp\bpl\ble\bes\bs
 E\bEx\bxe\ber\brc\bci\bis\bse\bes\bs
        Exercise 1:
 
-       Compute "3,2,*,1,+ and "3,2,1,+,*" by hand.  Rewrite them in tradi-
-       tional notation.  Explain why they have different answers.
+       Compute "3,2,*,1,+ and "3,2,1,+,*" by hand.  Rewrite them in
+       traditional notation.  Explain why they have different answers.
 
        Answer 1:
 
@@ -187,4 +187,4 @@ A\bAU\bUT\bTH\bHO\bOR\bR
 
 
 
-1.3.99909060808                   2008-12-22                    RPNTUTORIAL(1)
+1.3.999                           2009-05-10                    RPNTUTORIAL(1)