| 1 |
<?xml version="1.0"?> |
| 2 |
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" font-family="Times Roman" font-size="10pt" text-align="justify"> |
| 3 |
<fo:layout-master-set> |
| 4 |
<fo:simple-page-master master-name="blank" page-width="8.5in" page-height="11in" margin-top="1in" margin-bottom="1in" margin-left="10pc" margin-right="1in"> |
| 5 |
<fo:region-body margin-bottom="24pt" margin-top="24pt"/> |
| 6 |
<fo:region-before region-name="xsl-region-before-blank" extent="12pt"/> |
| 7 |
<fo:region-after region-name="xsl-region-after-blank" extent="12pt"/> |
| 8 |
</fo:simple-page-master> |
| 9 |
<fo:simple-page-master master-name="simple1" page-width="8.5in" page-height="11in" margin-top="1in" margin-bottom="1in" margin-left="10pc" margin-right="1in"> |
| 10 |
<fo:region-body margin-bottom="24pt" margin-top="24pt"/> |
| 11 |
<fo:region-before extent="12pt"/> |
| 12 |
<fo:region-after extent="12pt"/> |
| 13 |
</fo:simple-page-master> |
| 14 |
<fo:simple-page-master master-name="left1" page-width="8.5in" page-height="11in" margin-top="1in" margin-bottom="1in" margin-left="10pc" margin-right="1in"> |
| 15 |
<fo:region-body margin-bottom="24pt" margin-top="24pt"/> |
| 16 |
<fo:region-before region-name="xsl-region-before-left" extent="12pt"/> |
| 17 |
<fo:region-after region-name="xsl-region-after-left" extent="12pt"/> |
| 18 |
</fo:simple-page-master> |
| 19 |
<fo:simple-page-master master-name="right1" page-width="8.5in" page-height="11in" margin-top="1in" margin-bottom="1in" margin-left="1in" margin-right="10pc"> |
| 20 |
<fo:region-body margin-bottom="24pt" margin-top="24pt"/> |
| 21 |
<fo:region-before region-name="xsl-region-before-right" extent="12pt"/> |
| 22 |
<fo:region-after region-name="xsl-region-after-right" extent="12pt"/> |
| 23 |
</fo:simple-page-master> |
| 24 |
<fo:simple-page-master master-name="first1" page-width="8.5in" page-height="11in" margin-top="1in" margin-bottom="1in" margin-left="1in" margin-right="1in"> |
| 25 |
<fo:region-body margin-bottom="24pt" margin-top="24pt"/> |
| 26 |
<fo:region-before region-name="xsl-region-before-first" extent="12pt"/> |
| 27 |
<fo:region-after region-name="xsl-region-after-first" extent="12pt"/> |
| 28 |
</fo:simple-page-master> |
| 29 |
<fo:simple-page-master master-name="simple2" page-width="8.5in" page-height="11in" margin-top="1in" margin-bottom="1in" margin-left="10pc" margin-right="1in"> |
| 30 |
<fo:region-body column-count="1" margin-bottom="24pt" margin-top="24pt"/> |
| 31 |
<fo:region-before extent="12pt"/> |
| 32 |
<fo:region-after extent="12pt"/> |
| 33 |
</fo:simple-page-master> |
| 34 |
<fo:simple-page-master master-name="left2" page-width="8.5in" page-height="11in" margin-top="1in" margin-bottom="1in" margin-left="10pc" margin-right="1in"> |
| 35 |
<fo:region-body column-count="1" margin-bottom="24pt" margin-top="24pt"/> |
| 36 |
<fo:region-before region-name="xsl-region-before-left" extent="12pt"/> |
| 37 |
<fo:region-after region-name="xsl-region-after-left" extent="12pt"/> |
| 38 |
</fo:simple-page-master> |
| 39 |
<fo:simple-page-master master-name="right2" page-width="8.5in" page-height="11in" margin-top="1in" margin-bottom="1in" margin-left="1in" margin-right="10pc"> |
| 40 |
<fo:region-body column-count="1" margin-bottom="24pt" margin-top="24pt"/> |
| 41 |
<fo:region-before region-name="xsl-region-before-right" extent="12pt"/> |
| 42 |
<fo:region-after region-name="xsl-region-after-right" extent="12pt"/> |
| 43 |
</fo:simple-page-master> |
| 44 |
<fo:simple-page-master master-name="first2" page-width="8.5in" page-height="11in" margin-top="1in" margin-bottom="1in" margin-left="1in" margin-right="1in"> |
| 45 |
<fo:region-body column-count="1" margin-bottom="24pt" margin-top="24pt"/> |
| 46 |
<fo:region-before region-name="xsl-region-before-first" extent="12pt"/> |
| 47 |
<fo:region-after region-name="xsl-region-after-first" extent="12pt"/> |
| 48 |
</fo:simple-page-master> |
| 49 |
<fo:page-sequence-master master-name="titlepage1"> |
| 50 |
<fo:repeatable-page-master-alternatives> |
| 51 |
<fo:conditional-page-master-reference master-name="first1"/> |
| 52 |
</fo:repeatable-page-master-alternatives> |
| 53 |
</fo:page-sequence-master> |
| 54 |
<fo:page-sequence-master master-name="oneside1"> |
| 55 |
<fo:repeatable-page-master-alternatives> |
| 56 |
<fo:conditional-page-master-reference master-name="simple1"/> |
| 57 |
</fo:repeatable-page-master-alternatives> |
| 58 |
</fo:page-sequence-master> |
| 59 |
<fo:page-sequence-master master-name="twoside1"> |
| 60 |
<fo:repeatable-page-master-alternatives> |
| 61 |
<fo:conditional-page-master-reference master-name="blank" blank-or-not-blank="blank"/> |
| 62 |
<fo:conditional-page-master-reference master-name="right1" odd-or-even="odd"/> |
| 63 |
<fo:conditional-page-master-reference master-name="left1" odd-or-even="even"/> |
| 64 |
</fo:repeatable-page-master-alternatives> |
| 65 |
</fo:page-sequence-master> |
| 66 |
<fo:page-sequence-master master-name="titlepage2"> |
| 67 |
<fo:repeatable-page-master-alternatives> |
| 68 |
<fo:conditional-page-master-reference master-name="first2"/> |
| 69 |
</fo:repeatable-page-master-alternatives> |
| 70 |
</fo:page-sequence-master> |
| 71 |
<fo:page-sequence-master master-name="oneside2"> |
| 72 |
<fo:repeatable-page-master-alternatives> |
| 73 |
<fo:conditional-page-master-reference master-name="simple2"/> |
| 74 |
</fo:repeatable-page-master-alternatives> |
| 75 |
</fo:page-sequence-master> |
| 76 |
<fo:page-sequence-master master-name="twoside2"> |
| 77 |
<fo:repeatable-page-master-alternatives> |
| 78 |
<fo:conditional-page-master-reference master-name="blank" blank-or-not-blank="blank"/> |
| 79 |
<fo:conditional-page-master-reference master-name="right2" odd-or-even="odd"/> |
| 80 |
<fo:conditional-page-master-reference master-name="left2" odd-or-even="even"/> |
| 81 |
</fo:repeatable-page-master-alternatives> |
| 82 |
</fo:page-sequence-master> |
| 83 |
</fo:layout-master-set> |
| 84 |
<fo:page-sequence id="" hyphenate="true" master-name="oneside1" language="en"> |
| 85 |
<fo:static-content flow-name="xsl-region-after"> |
| 86 |
<fo:block text-align="center" font-size="10pt"> |
| 87 |
<fo:page-number/> |
| 88 |
</fo:block> |
| 89 |
</fo:static-content> |
| 90 |
<fo:flow flow-name="xsl-region-body"> |
| 91 |
<fo:block> |
| 92 |
<fo:block margin-left="-4pc" font-family="Helvetica"> |
| 93 |
<fo:block keep-with-next.within-column="always"> |
| 94 |
<fo:block font-size="16pt" font-weight="bold" font-family="Helvetica" space-before.minimum="1em" space-before.optimum="1.5em" space-before.maximum="2em">Loops</fo:block> |
| 95 |
</fo:block> |
| 96 |
</fo:block> |
| 97 |
</fo:block> |
| 98 |
<fo:block space-before.optimum="1em" space-before.minimum="0.8em" space-before.maximum="1.2em"> |
| 99 |
<fo:wrapper id="id2781313"><!--for loop, DSSSL and--></fo:wrapper> |
| 100 |
<fo:wrapper id="id2781330"><!--loops, implementing (DSSSL)--></fo:wrapper> |
| 101 |
<fo:wrapper id="id2781348"><!--tail recursion (DSSSL)--></fo:wrapper> |
| 102 |
|
| 103 |
DSSSL doesn't have any construct that resembles the |
| 104 |
for loop that occurs in most imperative languages like C |
| 105 |
and Java. Instead, DSSSL employs a common trick in |
| 106 |
functional languages for implementing a loop: tail recursion. |
| 107 |
</fo:block> |
| 108 |
<fo:block space-before.optimum="1em" space-before.minimum="0.8em" space-before.maximum="1.2em"> |
| 109 |
Loops in DSSSL use a special form of |
| 110 |
<fo:inline font-family="Courier">let</fo:inline>. This loop counts from 1 to 10: |
| 111 |
<fo:block wrap-option="no-wrap" text-align="start" white-space-collapse="false" linefeed-treatment="preserve" font-family="Courier" font-size="9pt" space-before.minimum="0.8em" space-before.optimum="1em" space-before.maximum="1.2em"> |
| 112 |
(let <fo:inline id="dl1">❶</fo:inline>loopvar <fo:inline id="dl2">❷</fo:inline>((count 1)) |
| 113 |
<fo:inline id="dl3">❸</fo:inline>(if (> count 10) |
| 114 |
<fo:inline id="dl4">❹</fo:inline>#t |
| 115 |
(<fo:inline id="dl5">❺</fo:inline>loopvar <fo:inline id="dl6">❻</fo:inline>(+ count 1))))</fo:block></fo:block> |
| 116 |
<fo:block id="id2785036"> |
| 117 |
<fo:list-block space-before.optimum="1em" space-before.minimum="0.8em" space-before.maximum="1.2em" provisional-distance-between-starts="2.2em" provisional-label-separation="0.2em"> |
| 118 |
<fo:list-item id="id2785045"> |
| 119 |
<fo:list-item-label end-indent="label-end()"> |
| 120 |
<fo:block>❶</fo:block> |
| 121 |
</fo:list-item-label> |
| 122 |
<fo:list-item-body start-indent="body-start()"> |
| 123 |
<fo:block>This variable controls the loop. It is declared without an |
| 124 |
initial value, immediately after the <fo:inline font-family="Courier">let</fo:inline> |
| 125 |
operand.</fo:block> |
| 126 |
</fo:list-item-body> |
| 127 |
</fo:list-item> |
| 128 |
<fo:list-item id="id2785112"> |
| 129 |
<fo:list-item-label end-indent="label-end()"> |
| 130 |
<fo:block>❷</fo:block> |
| 131 |
</fo:list-item-label> |
| 132 |
<fo:list-item-body start-indent="body-start()"> |
| 133 |
<fo:block> |
| 134 |
<fo:wrapper id="id2785136"><!--variables (DSSSL), local, defining after loop variable--></fo:wrapper> |
| 135 |
|
| 136 |
Any number of additional local variables can be defined after |
| 137 |
the loop variable, just as they can in any other |
| 138 |
<fo:inline font-family="Courier">let</fo:inline> expression.</fo:block> |
| 139 |
</fo:list-item-body> |
| 140 |
</fo:list-item> |
| 141 |
<fo:list-item id="id2785185"> |
| 142 |
<fo:list-item-label end-indent="label-end()"> |
| 143 |
<fo:block>❸</fo:block> |
| 144 |
</fo:list-item-label> |
| 145 |
<fo:list-item-body start-indent="body-start()"> |
| 146 |
<fo:block>If you ever want the loop to end, you have to put some sort of a |
| 147 |
test in it.</fo:block> |
| 148 |
</fo:list-item-body> |
| 149 |
</fo:list-item> |
| 150 |
<fo:list-item id="id2785017"> |
| 151 |
<fo:list-item-label end-indent="label-end()"> |
| 152 |
<fo:block>❹</fo:block> |
| 153 |
</fo:list-item-label> |
| 154 |
<fo:list-item-body start-indent="body-start()"> |
| 155 |
<fo:block>This is the value that will be returned.</fo:block> |
| 156 |
</fo:list-item-body> |
| 157 |
</fo:list-item> |
| 158 |
<fo:list-item id="id2781490"> |
| 159 |
<fo:list-item-label end-indent="label-end()"> |
| 160 |
<fo:block>❺</fo:block> |
| 161 |
</fo:list-item-label> |
| 162 |
<fo:list-item-body start-indent="body-start()"> |
| 163 |
<fo:block>Note that you iterate the loop by using the loop variable as if |
| 164 |
it was a function name.</fo:block> |
| 165 |
</fo:list-item-body> |
| 166 |
</fo:list-item> |
| 167 |
<fo:list-item id="id2781524"> |
| 168 |
<fo:list-item-label end-indent="label-end()"> |
| 169 |
<fo:block>❻</fo:block> |
| 170 |
</fo:list-item-label> |
| 171 |
<fo:list-item-body start-indent="body-start()"> |
| 172 |
<fo:block>The arguments to this function are the values that |
| 173 |
you want the local variables declared in <fo:basic-link internal-destination="dl2">❷</fo:basic-link> to have |
| 174 |
in the next iteration.</fo:block> |
| 175 |
</fo:list-item-body> |
| 176 |
</fo:list-item> |
| 177 |
</fo:list-block> |
| 178 |
</fo:block> |
| 179 |
</fo:flow> |
| 180 |
</fo:page-sequence> |
| 181 |
</fo:root> |