| Search internet |
Earlier, you populated the foo directory with several .lgs files. Now compile combinations.lgs:
> lgc combinations
Then view it:
> firefox combinations/index.html & Click 'Main page'
A numbered version of combinations.lgs looks thus:
1 "";;0143BAB3BC67212340C9406BDB560819F3DCD4E859FC96F7B1C2B2BB0806
2 ""P combinations
3
4 ""R base
5
6 ""D 0
7 (( " , " ))
8
9 ""B
10 page ( ""N , ""C )
11 title "Combinations"
12 bib "
13 @techreport{appendix,
14 author = {A. U. Thor},
15 year = {2006},
16 title = {Combinations - appendix},
17 institution={Logiweb},
18 note =
19 {\href{\lgwBlockRelay \lgwBlockThis /page/appendix.pdf}{%
20 \lgwBreakRelay \lgwBreakThis /page/appendix.pdf}}}
21 "
22 main text "
23 \title{Combinations}
24 \author{A. U. Thor}
25 \maketitle
26 \tableofcontents
27 \section{Combinations}
28 The number of combinations of size "[[ k ]]" from a set
29 of size "[[ n ]]" is given by the binomial coefficient
30 "[[ (( n , k )) = n factorial div k factorial
31 div ( n - k ) factorial ]]". A recursive definition
32 of "[[ (( n , k )) ]]" may be stated thus:
33 "[[[ value define (( n , k )) as if k = 0 then 1
34 else (( n - 1 , k - 1 )) * n div k end define ]]]"
35 As an example, we have "[[ ttst (( 4 , 2 )) = 6 end test ]]".
36 For details on how the binomial coefficient is rendered, see
37 \cite{appendix}.
38 \bibliography{./page}
39 "
40 appendix "
41 \title{Combinations - appendix}
42 \author{A. U. Thor}
43 \maketitle
44 \tableofcontents
45 \section{\TeX\ definitions}
46 \begin{statements}
47 \item "[[ tex show define (( n , k )) as "
48 \left( \begin{array}{l} "[ n ]"
49 \\ "[ k ]"
50 \end{array}\right)" end define ]]"
51 \end{statements}
52 "
53 end page
54
55
56
57
Some of this should look familiar. Line 1 is a comment (though a quite special one). Line 2 names the page. Line 4 references the base page. Lines 10-53 contain a page...end page construct which generates a reasonable rendering.
Lines 6-9 define a construct (( m , n )). The lgc compiler adds this construct to the grammar such that it can be used in the body of the page.
The D escape sequence in Line 6 starts a definition section (D for Definition) and the B escape sequence in Line 9 indicates that the definition section ends so that the body of the page begins or continues at that point (B for Body).
Each non-empty line of a definition section defines a construct. In constructs, double quote characters serve as placeholders.
By convention, a page should have one P escape sequence followed by zero, one, or more R escape sequences followed by zero, one, or more definition sections followed by the body. But lgc(1) does not care about the order. If it is convenient for you to have definition sections in the middle of the source code and the P escape at the end, that is up to you. At present, P, R, D, and B escapes cannot occur inside strings so they cannot occur absolutely everywhere, but it is the intension to allow that also at a later stage. The body comprises everything left when P, R, D, and B directives are removed.
| Search logiweb.eu |