| 1 |
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?> |
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?> |
| 2 |
<page name="demo" leftbar="false"> |
<!DOCTYPE page [ |
| 3 |
|
<!ENTITY leq "≤"> <!-- LESS_THAN OR EQUAL TO --> |
| 4 |
|
]> |
| 5 |
|
<page name="demo"> |
| 6 |
<title>CDuce demo</title> |
<title>CDuce demo</title> |
| 7 |
|
|
| 8 |
|
<box title="Types, pattern matching" link="typpm"> |
| 9 |
|
<demo label="1"><include-verbatim file="funxml_types.cd"/><![CDATA[ |
| 10 |
|
let title(Book -> String) <book>[ <title>x _* ] -> x |
| 11 |
|
let authors(Book -> [Author+]) <_>[ (x::Author|_)* ] -> x |
| 12 |
|
]]> |
| 13 |
|
</demo> |
| 14 |
|
</box> |
| 15 |
|
|
| 16 |
|
<box title="Printing functions" link="printfun"> |
| 17 |
|
<demo prefix="1"><![CDATA[ |
| 18 |
|
type FBook = Book -> String |
| 19 |
|
type ABook = <book print=FBook>[ Title Subtitle? Author+ ] |
| 20 |
|
type ABib = [ ABook* ] |
| 21 |
|
(* Remark: ABook <= Book, ABib <= Bib *) |
| 22 |
|
|
| 23 |
|
let set(<book>c : Book)(f : FBook) : ABook = <book print=f>c |
| 24 |
|
let prepare(b : Bib) : ABib = map b with x -> set x title |
| 25 |
|
|
| 26 |
|
let b : Bib = |
| 27 |
|
[ <book>[ <title>"T" <subtitle>"S" <author>"A" ] ] |
| 28 |
|
|
| 29 |
|
let ab = prepare b |
| 30 |
|
]]> |
| 31 |
|
</demo> |
| 32 |
|
|
| 33 |
|
</box> |
| 34 |
|
|
| 35 |
|
|
| 36 |
|
<!-- |
| 37 |
|
#silent |
| 38 |
|
let b1 : Book = <book>[ |
| 39 |
|
<title>[ 'Object-Oriented Programming' ] |
| 40 |
|
<subtitle>[ 'A Unified Foundation' ] |
| 41 |
|
<author>[ 'Castagna' ] ] |
| 42 |
|
let b2 : Book = <book>[ |
| 43 |
|
<title>[ 'Persistent Object Systems' ] |
| 44 |
|
<author>[ 'Atkinson' ] |
| 45 |
|
<author>[ 'Benzaken' ] |
| 46 |
|
<author>[ 'Maier' ] ] |
| 47 |
|
let v : Bib = [ b1 b2 ] |
| 48 |
|
#verbose |
| 49 |
|
|
| 50 |
|
let z = authors b1 |
| 51 |
|
]]> |
| 52 |
|
</demo> |
| 53 |
|
</box> |
| 54 |
|
--> |
| 55 |
|
|
| 56 |
|
<!-- |
| 57 |
<box title="XML elements" link="xml"> |
<box title="XML elements" link="xml"> |
| 58 |
<p>XML elements.</p> |
<p>XML elements.</p> |
| 59 |
<demo><include-verbatim file="examples/xml.cd"/></demo> |
<demo><include-verbatim file="examples/xml.cd"/></demo> |
| 124 |
matching.</p> |
matching.</p> |
| 125 |
<demo><include-verbatim file="examples/pm_compil.cd"/></demo> |
<demo><include-verbatim file="examples/pm_compil.cd"/></demo> |
| 126 |
</box> |
</box> |
| 127 |
|
--> |
| 128 |
|
|
| 129 |
</page> |
</page> |