| 2 |
<page name="demo"> |
<page name="demo"> |
| 3 |
<title>CDuce demo</title> |
<title>CDuce demo</title> |
| 4 |
|
|
| 5 |
|
<box title="XML elements" link="xml"> |
| 6 |
|
<p>XML elements.</p> |
| 7 |
|
<demo><include-verbatim file="examples/xml.cd"/></demo> |
| 8 |
|
</box> |
| 9 |
|
|
| 10 |
|
<box link="functions" title="Functions"> |
| 11 |
|
<p>Several syntaxes to define functions.</p> |
| 12 |
|
<demo><include-verbatim file="examples/functions.cd"/></demo> |
| 13 |
|
</box> |
| 14 |
|
|
| 15 |
|
<box link="mutrec" title="Mutual recursion"> |
| 16 |
|
<p>Mutual toplevel definition for types and functions.</p> |
| 17 |
|
<demo><include-verbatim file="examples/mutrec.cd"/></demo> |
| 18 |
|
</box> |
| 19 |
|
|
| 20 |
|
<box link="sequence" title="Sequence literals"> |
| 21 |
|
<p>How to write sequences.</p> |
| 22 |
|
<demo><include-verbatim file="examples/sequence.cd"/></demo> |
| 23 |
|
</box> |
| 24 |
|
|
| 25 |
|
<box link="seqtypes" title="Sequence types"> |
| 26 |
|
<p>Types for sequences.</p> |
| 27 |
|
<demo><include-verbatim file="examples/seqtypes.cd"/></demo> |
| 28 |
|
</box> |
| 29 |
|
|
| 30 |
|
<box link="integers" title="The factorial function"> |
| 31 |
|
<p>What about computing 10000! ?</p> |
| 32 |
|
<demo><include-verbatim file="examples/integers.cd"/></demo> |
| 33 |
|
</box> |
| 34 |
|
|
| 35 |
|
<box link="sumtype" title="Sum types"> |
| 36 |
|
<p>How to simulate ML sum types.</p> |
| 37 |
|
<demo><include-verbatim file="examples/sumtype.cd"/></demo> |
| 38 |
|
</box> |
| 39 |
|
|
| 40 |
|
<box link="ovfun" title="Overloaded functions"> |
| 41 |
|
<p>This examples demonstrates the use of overloaded functions.</p> |
| 42 |
|
<demo><include-verbatim file="examples/ovfun.cd"/></demo> |
| 43 |
|
</box> |
| 44 |
|
|
| 45 |
|
<box link="note" title="Footnotes"> |
| 46 |
|
<p>This example shows how to bind an XML element with surrounding text.</p> |
| 47 |
|
<demo><include-verbatim file="examples/note.cd"/></demo> |
| 48 |
|
</box> |
| 49 |
|
|
| 50 |
|
<box link="biblio" title="Bibliography"> |
| 51 |
|
<p>The good old XML bibliography example.</p> |
| 52 |
|
<demo><include-verbatim file="examples/biblio.cd"/></demo> |
| 53 |
|
</box> |
| 54 |
|
|
| 55 |
|
<box link="projection" title="Projection"> |
| 56 |
|
<p>Syntactic sugar for projection.</p> |
| 57 |
|
<demo><include-verbatim file="examples/projection.cd"/></demo> |
| 58 |
|
</box> |
| 59 |
|
|
| 60 |
|
<box link="xtransform" title="Tree transformations"> |
| 61 |
|
<p>How to perform XSLT-like transformations.</p> |
| 62 |
|
<demo><include-verbatim file="examples/xtransform.cd"/></demo> |
| 63 |
|
</box> |
| 64 |
|
|
| 65 |
|
<box link="reference" title="References"> |
| 66 |
|
<p>Mutable values.</p> |
| 67 |
|
<demo><include-verbatim file="examples/reference.cd"/></demo> |
| 68 |
|
</box> |
| 69 |
|
|
| 70 |
<box title="Compilation of pattern matching" link="pm_compil"> |
<box title="Compilation of pattern matching" link="pm_compil"> |
| 71 |
<p>This example demonstrates the efficient compilation of pattern |
<p>This example demonstrates the efficient compilation of pattern |
| 72 |
matching.</p> |
matching.</p> |
| 73 |
<demo><include-verbatim file="examples/pm_compil.cd"/></demo> |
<demo><include-verbatim file="examples/pm_compil.cd"/></demo> |
| 74 |
</box> |
</box> |
| 75 |
|
|
|
<box title="Integers" link="ints"> |
|
|
<p> |
|
|
Let's begin with integers, arithmetic, and, obviously, the |
|
|
factorial function. |
|
|
</p> |
|
|
<demo> |
|
|
let x = 2;; |
|
|
let a = x * 10;; |
|
|
|
|
|
<include-verbatim file="examples/integers.cd"/> |
|
|
</demo> |
|
|
</box> |
|
|
|
|
|
<box title="Strings" link="strs"> |
|
|
<demo> |
|
|
let x = "abc";; |
|
|
let a = [ !x 'xyz' ] @ "123";; |
|
|
</demo> |
|
|
</box> |
|
|
|
|
| 76 |
</page> |
</page> |