/[svn]/web/examples.xml
ViewVC logotype

Contents of /web/examples.xml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1369 - (show annotations)
Tue Jul 10 18:43:19 2007 UTC (5 years, 10 months ago) by abate
File MIME type: text/xml
File size: 2969 byte(s)
[r2004-12-26 00:19:23 by afrisch] new compilation (doesn't work yet)

Original author: afrisch
Date: 2004-12-26 00:19:24+00:00
1 <?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
2 <page name="examples">
3
4 <title>Advanced examples</title>
5
6 <left>
7 <p>This page presents some sample CDuce programs.</p>
8 <boxes-toc/>
9 <p>See also:</p>
10 <local-links href="index,proto,memento"/>
11 </left>
12
13
14 <box title="Advanced examples" link="start">
15
16 This page presents some advanced programming examples in CDuce. <b
17 style="color:#FF0080">If you never saw CDuce programs before, this is the wrong
18 page</b> to start with. Rather follow our <local href="tutorial"/>, or test the
19 simple examples in our <a href="http://reglisse.ens.fr/cgi-bin/cduce">on line demo</a>.
20
21 </box>
22
23
24 <box title="Our canonical example" link="sort">
25 <p>
26 The example below is the one we use to demonstrate
27 how overloaded functions can avoid duplicating code.
28 Without overloaded functions, we would need to define
29 two mutually recursive functions in order to type-check
30 the transformation. Here, two constraints
31 in the (highlighted) function interface
32 can express precisely the behaviour of the function.
33 A detailed explanation of the code can be found <a href="tutorial_overloading.html#canonical">here</a>.
34 </p>
35 <sample>
36 <include-verbatim file="overloading.cd"/>
37 </sample>
38 </box>
39
40 <box title="Datatypes + first-class functions" link="data">
41 <p>
42 The program below shows how to simulate ML data types in CDuce.
43 It implements a (naive backtracking) regular expression recognizer.
44 The examples also demonstrate the use of first-class functions
45 (used as continuations).
46 </p>
47 <p>
48 Exercise for the reader: show that the algorithm may not terminate for
49 some special regular expressions.
50 </p>
51 <sample highlight="false">
52 <include-verbatim file="regexp.cd"/>
53 </sample>
54 </box>
55
56 <box title="First-class functions and XML together" link="funxml">
57 <p>
58 The program below illustrates the use of first-class functions stored
59 in (pseudo) XML documents.
60 </p>
61 <sample highlight="false">
62 <include-verbatim file="funxml.cd"/>
63 </sample>
64 </box>
65
66 <box title="CDuce quine" link="quine">
67 <p>
68 A quine (a.k.a. self-rep) is a program that produces its own source
69 code. Here is an example of a quine written in CDuce.
70 </p>
71 <sample highlight="false">
72 <include-verbatim file="quine.cd"/>
73 </sample>
74 </box>
75
76 <box title="The script that generates this site" link="site">
77 <p>
78 The script below is one of the longest CDuce application ever written
79 ;-) It is used to produce all the pages of this web site (except
80 the <local href="proto">web prototype</local> which is
81 a CGI script written in OCaml). CDuce type system ensures
82 that produced pages are valid w.r.t XHTML 1.0 Strict.
83 </p>
84 <p>
85 This program features both XML and text-content manipulation.
86 It also demonstrates the use of non-XML internal data structures.
87 Here, a tree represents internally the site
88 structure, and a list represents the path from the
89 root to the current page (in order to display the "You're here" line).
90 </p>
91 <sample highlight="false">
92 <include-verbatim file="site.cd"/>
93 </sample>
94 </box>
95
96 </page>
97

CVS Admin">CVS Admin
ViewVC Help
Powered by ViewVC 1.1.5